I have a Ruby app (written in Roda, running as a Rack app on Puma) which I want to be able to stop on a click of a button in the browser - basically to stop the server on request. What would be a good way to do that?
我没有对此进行测试,但是由于您可以使用system
从控制器运行 shell 命令,因此您可以在页面上设置一个按钮,使用 shell 命令触发特定的控制器操作以停止服务器,例如system "system killall -9 rails"
停止运行名称中带有 rails 的应用程序,或者任何更具体的针对您的情况的应用程序。
You can control Puma with process signals. If you are running Puma in a single process, you can simply send the signal to the current process:
Process.kill("TERM", Process.pid)
For a clustered mode you will have to find the PID of Puma master process.
Puma also offers a built-in control/status web server if you don't want to write your own.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.