0

在我的服务器上,我可以启动我的 Rails 应用程序服务器 (puma),并通过 cd'ing 进入应用程序的根目录并发出以下命令,为我的应用程序提供一个 UNIX 套接字:

bundle exec puma -e production -b unix:///var/run/my_app.sock

一切正常,希望我的服务器终端现在没用了:

Puma starting in single mode...
* Version 2.6.0, codename: Pantsuit Party
* Min threads: 0, max threads: 16
* Environment: production
* Listening on unix:///var/run/my_app.sock
Use Ctrl-C to stop

这可能主要是 n00by,但我真的不知道在这里做什么。

我不能 CTRL-C,因为那会阻止 puma。

我不能只关闭终端窗口,因为那样也会停止 puma。

难题!

4

1 回答 1

2

You can use the --daemon option to make puma fork to the background. That way, it will free your terminal as soon as it ends the startup process.

To make the process exit afterwards, you need to send it the TERM signal:

kill -TERM $PID

Where $PID stands for puma's process id. The easiest way to get that on a server is to ask puma to save its pid on a file (a, suitably named, "pidfile"), using the --pidfile option when starting it up.

For more options, check out puma's documentation and examples on github: https://github.com/puma/puma

于 2013-11-11T23:31:21.363 回答