Run background process in Sinatra

折月煮酒 提交于 2019-12-06 02:05:13

I have had success with this (simplified) in Sinatra:

get '/start_process'
  @@pid = Process.spawn('external_command_to_run')
end

This returns the Process ID, which you can use to terminate the process later if you need. Also, this is on Linux, it will not work on Windows.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!