【发布时间】:2015-08-25 14:53:18
【问题描述】:
现在,在加载完所有内容后,我的可执行文件会像这样运行我的应用程序:
Rack::Handler::pick(['puma']).run VCK::App
它可以工作,但它会阻塞终端(这对于开发来说是可以的)
如何从我的可执行文件中以编程方式将其作为守护程序启动?
编辑:
我用来启动 sinatra 作为守护进程的代码:
if options[:daemonize]
pid = fork {Rack::Handler::pick(['puma']).run VCK::App}
File.open(pid_file_loc, 'w') {|f| f.write(pid)}
Process.detach(pid)
else
Rack::Handler::pick(['puma']).run VCK::App
end
我用来停止 Sinatra 守护进程的代码:
Process.kill(15, File.read(pid_file_loc).to_i)
【问题讨论】: