独角兽在开始时冻结

Unicorn Freezes on Start

我正在进行一些故障排除以找出我的网站无法加载的原因。

我正在使用 Amazon OopsWorks。我有一个 Amazon Linux 服务器 运行ning Rails 4.2.0 和 Ruby 2.2.0。我正在使用 Nginx 和 Unicorn。我已经验证 Nginx 是 运行ning。当我尝试使用 bundle exec unicorn -E production -c /srv/www/likeminds/current/config/unicorn.rb 启动 Unicorn 时,我没有收到错误消息。实际上,我什么也没得到。就是这个问题,没有任何反应。

独角兽怎么了?似乎它在开始时就冻结了。在此先感谢您的帮助。

这是我服务器上 运行ning 的内容。

 2278 aws       20   0  323m  69m 4212 S  0.7  7.0   0:00.99 opsworks-agent     
    1 root      20   0 19596 1608 1292 S  0.0  0.2   0:00.55 init               
    2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd           
    3 root      20   0     0    0    0 S  0.0  0.0   0:00.81 ksoftirqd/0        
    5 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 kworker/0:0H       
    6 root      20   0     0    0    0 S  0.0  0.0   0:00.08 kworker/u30:0      
    7 root      20   0     0    0    0 S  0.0  0.0   0:00.54 rcu_sched          
    8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 rcu_bh             
    9 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0        
   10 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 khelper            
   11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kdevtmpfs          
   12 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 netns              
   13 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kworker/u30:1      
   19 root      20   0     0    0    0 S  0.0  0.0   0:00.00 xenwatch           
   20 root      20   0     0    0    0 S  0.0  0.0   0:00.00 xenbus             
   21 root      20   0     0    0    0 S  0.0  0.0   0:00.09 kworker/0:1        
  115 root       0 -20     0    0    0 S  0.0  0.0   0:00.00 writeback   

更新我的 Unicorn.rb 文件无效。现在 EC2 输出

/home/deploy/.bundler/likeminds/ruby/2.2.0/gems/unicorn-4.9.0/lib/unicorn/configurator.rb:657:in `parse_rackup_file': rackup file (config.ru) not readable (ArgumentError)

这是导致独角兽冻结的Unicorn.rb

# Set the working application directory
# working_directory "/path/to/your/app"
working_directory "/srv/www/likeminds/current/"

# Unicorn PID file location
# pid "/path/to/pids/unicorn.pid"
pid "/srv/www/likeminds/shared/pids/unicorn.pid"

# Path to logs
# stderr_path "/path/to/log/unicorn.log"
# stdout_path "/path/to/log/unicorn.log"
stderr_path "/srv/www/likeminds/shared/log/unicorn.log"
stdout_path "/srv/www/likeminds/shared/log/unicorn.log"

# Unicorn socket
listen "/srv/www/likeminds/shared/sockets/unicorn.likeminds.sock"
listen "/srv/www/likeminds/shared/sockets/unicorn.likeminds.sock"

# Number of processes
# worker_processes 4
worker_processes 2

# Time-out
timeout 30

这是输出错误的版本,但在我的本地主机上 运行 成功。

if ENV["RAILS_ENV"] == "development"
  worker_processes 1
else
  worker_processes 3
end

timeout 30

更新##

更改权限后,我可以启动 Unicorn。但我收到错误。

E, [2015-05-17T00:21:47.129959 #7004] ERROR -- : reaped #<Process::Status: pid 8943 exit 1> worker=0
I, [2015-05-17T00:21:47.130085 #7004]  INFO -- : worker=0 spawning...
I, [2015-05-17T00:21:47.130878 #8953]  INFO -- : worker=2 spawned pid=8953
I, [2015-05-17T00:21:47.132421 #8953]  INFO -- : Refreshing Gem list
I, [2015-05-17T00:21:47.136806 #8955]  INFO -- : worker=0 spawned pid=8955
I, [2015-05-17T00:21:47.140432 #8955]  INFO -- : Refreshing Gem list
E, [2015-05-17T00:21:50.288644 #8950] ERROR -- : undefined local variable or method `ru' for #<LikeMinds::Apps

从命令行手动检查应该会显示一些输出。例如,我看到:

I, [2015-05-16T16:36:12.487217 #63958]  INFO -- : listening on addr=0.0.0.0:8080 fd=9
I, [2015-05-16T16:36:12.487321 #63958]  INFO -- : worker=0 spawning...
I, [2015-05-16T16:36:12.488381 #63958]  INFO -- : master process ready
I, [2015-05-16T16:36:12.489353 #63959]  INFO -- : worker=0 spawned pid=63959
I, [2015-05-16T16:36:12.489799 #63959]  INFO -- : Refreshing Gem list
I, [2015-05-16T16:36:16.198329 #63959]  INFO -- : worker=0 ready

您是否看到任何使用此方法或在 unicorn.sterr.log 中的内容?请post你的独角兽配置文件​​。

解决方案:pid 文件路径似乎无法被 unicorn 进程写入。更改权限以允许进程所有者访问似乎有效。