如何在 Rails 中停止守护进程? [英] How to stop a Daemon Server in Rails?

查看:42
本文介绍了如何在 Rails 中停止守护进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下内容运行我的 rails 应用程序

I am running my rails application using the following

  $script/server -d webrick 

在我的 Ubuntu 系统上,上面的命令在后台运行 webrick 服务器.我可以使用 kill 命令

on my Ubuntu system , above command run the webrick server in background . I could kill the process using kill command

  $kill pid

rails 是否提供任何命令来停止后台运行的守护程序服务器?

Does rails provide any command to stop the background running daemon server ?

就像rails提供的启动服务器一样,谢谢.

like the one provided by rails to start the server , Thanks .

EDIT 什么时候启动守护程序服务器比较合适?任何实时场景都会有所帮助谢谢

EDIT When it is appropriate to start the daemon server ? Any real time scenario will help Thanks

推荐答案

rake 任务怎么样?

How about a rake task?

desc 'stop rails'
task :stop do
    pid_file = 'tmp/pids/server.pid'
    pid = File.read(pid_file).to_i
    Process.kill 9, pid
    File.delete pid_file
end

使用 rake stop 或 sudo rake stop 运行

run with rake stop or sudo rake stop

这篇关于如何在 Rails 中停止守护进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆