-1

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?

art-solopov
  • 4,289
  • 3
  • 25
  • 44

2 Answers2

0

I have not tested this but since you can run shell commands from a controller using system, you could setup a button on your page triggering a specific controller action with the shell command to stop your server, ex something like system "system killall -9 rails" to stop running apps with rails in their name, or anything more specific to your case.

Guillaume Bihet
  • 625
  • 1
  • 9
  • 17
0

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.

Simon Perepelitsa
  • 20,350
  • 8
  • 55
  • 74