Ruby on rails monit在生产服务器中找不到unicorn worker

Ruby on rails monit在生产服务器中找不到unicorn worker,ruby-on-rails,ruby-on-rails-3,nginx,unicorn,monit,Ruby On Rails,Ruby On Rails 3,Nginx,Unicorn,Monit,我正在使用这个gem进行部署 这是我的独角兽配置: 我的部署中有: server "111.111.111.111", :web, :app, :db, primary: true set :application, 'myapp' set :user, "hyperrjas" set :deploy_to, "/home/#{user}/apps/#{application}" set :deploy_via, :remote_cache set :use_sudo, false s

我正在使用这个gem进行部署

这是我的独角兽配置:

我的部署中有:

server "111.111.111.111", :web, :app, :db, primary: true

set :application, 'myapp'
set :user, "hyperrjas"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false

set :scm, "git"
set :repository, "path_to_my_remote_reposytory.git"
set :branch, "master"
set :current_path, "/home/#{user}/apps/#{application}/current"
set :shared_path, "/home/#{user}/apps/#{application}/shared"

set :unicorn_workers, 1
set :unicorn_pid, "#{shared_path}/pids/unicorn.pid"
set :server_name, "myserver.com"
这是我在远程服务器中的pid:

ps aux | grep unicorn
1000      6037  0.4 12.5 320464 127628 ?       Sl   14:09   0:37 unicorn master -c /home/hyperrjas/apps/myapp/shared/config/unicorn.rb -D                                                         
1000      6079  0.2 13.8 335784 140828 ?       Sl   14:10   0:17 unicorn worker[0] -c /home/hyperrjas/apps/myapp/shared/config/unicorn.rb -D                                                      
1000      6322  0.0  0.0   9384   868 pts/0    S+   16:14   0:00 grep unicorn
这是我的
config/deploy/templates/monit/unicorn.erb
文件:

check process myapp_unicorn with pidfile /home/hyperrjas/apps/myapp/current/tmp/pids/unicorn.pid
start program = "/etc/init.d/unicorn_myapp start"
stop program = "/etc/init.d/unicorn_myapp force-stop"

check process myapp_unicorn_worker_0 with pidfile /home/hyperrjas/apps/myapp/current/tmp/pids/unicorn.0.pid
start program = "/bin/true"
stop program = "/usr/bin/test -s /home/hyperrjas/apps/myapp/current/tmp/pids/unicorn.0.pid && /bin/kill -QUIT `cat /home/hyperrjas/apps/myapp/current/tmp/pids/unicorn.0.pid`"
if mem > 200.0 MB for 5 cycles then restart
if cpu > 50% for 15 cycles then restart
if 5 restarts within 25 cycles then timeout
alert myapp@gmail.com only on { pid }
if changed pid 2 times within 64 cycles then alert
我可以在monit中看到unicorn worker pid的下一条路径:

Pid file /home/hyperrjas/apps/myapp/current/tmp/pids/unicorn.0.pid
以及信息:

Status  Not monitored
远程服务器中的unicorn pid位于
/home/myapp/apps/myapp/current/tmp/pids/unicorn.pid

/home/hyperjas/apps/myapp/current/tmp/pids/

莫尼特正在监控独角兽pid

如何使用monit监视我的unicorn worker?

我在设置monit以监视我的Linode上三个不同应用程序的unicorn master和worker进程时使用的。引导您完成设置以及每件事情如何协同工作

我不建议尝试动态地为unicorn生成monit配置,相反,我会告诉unicorn始终将PID写入应用程序中的相同文件名,然后在monit配置中引用这些文件


如果你陷入困境,请告诉我,我会帮你的。另外,如果我的配置有帮助,请告诉我,我会发布。

谢谢您的回复。我正在使用这个gem进行部署,除了unicorn worker的monit之外,其他一切都很好。我认为问题在于
Monit
无法在
/home/hyperrjas/apps/myapp/current/tmp/pids/
文件夹中看到
unicorn.0.pid
。我在这个文件夹中有两个文件:
delayed\u job.pid
unicorn.pid
。非常感谢这可能是因为在您部署时,
当前
目录已被重新符号链接。尝试点选unicorn将PID文件存储在
/home/hyperjas/apps/myapp/shared/pids
或类似文件中,由于
共享
目录不会更改。我已将我的pid文件夹更改为
/home/hyperjas/apps/myapp/shared/pids
,我遇到了相同的问题:我可以在monit中看到我的独角兽工作人员出现红色消息
执行失败
。我可以在monit
Pid文件/home/hyperjas/apps/myapp/shared/pids/unicorn.0.Pid中看到。但是我在
/home/hyperrjas/apps/myapp/shared/pids/
中看不到这个pid文件,我只能看到一个文件:
unicorn.pid
非常感谢!我在问题中添加了我的独角兽配置。非常感谢你!通读这篇文章,让我知道它是否有帮助,特别是“after_fork”部分: