PHP 中是否有类似 exit或 die的方法可以停止 Ruby 脚本的执行?
exit
die
Either abort or exit will help.
abort
abort is an alias for Kernel.exit(false) which terminates execution immediately.
Kernel.exit(false)
exit is an alias for Kernel.exit(true) and raises the SystemExit exception, that may be caught. Also at_exit functions and finalizers are run before termination.
Kernel.exit(true)
SystemExit
at_exit
finalizers
abort can still hang if there's threads that are waiting. If you really want to terminate immediately try:
Process.kill 9, Process.pid
FYI for ruby on rails, you can simply use this gem shutup, in the rails directory run this command in the bash terminal
shutup
gem install shutup
it will find the PID of rails server and kill it.
and also you can do it with lsof -wi tcp:3000 in case you didnt start the server on another port otherwise you should change the port 3000
lsof -wi tcp:3000
3000