我有一个从我的 Sinatra 应用程序中的助手调用的部署脚本。
我想显示一个“正在部署”的 View /页面,然后执行脚本。
然后当脚本完成时,显示一个带有文本框的新页面,其中包含脚本输出。
如何做到这一点?
# update.rb - the main app
helpers do
def run_update
command = "./script.sh"
@ok = system( command )
end
end
post '/version' do
run_update # putting this after the erb call doesnt fix it!?
erb :version
end
目前它在从主页发布帖子后挂起。然后当脚本完成时,它会显示 version.erb 文件。
最佳答案
我想我要找的是 IO#popen
Runs the specified command as a subprocess; the subprocess’s standard input and output will be connected to the returned IO object.
关于ruby-on-rails - 执行脚本并在 View 中显示输出/进度 [Ruby/Sinatra(Rails)],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7187988/