rails
只要禁用 Spring ,我就可以在生产环境 (FreeBSD 10) 中执行-commands :
# DISABLE_SPRING=1 bin/rails runner -e production 'p "test"'
"test"
# script/rails runner -e production 'p "test"'
"test"
使用 Spring,rails
-command 失败并出现以下错误:
# bin/rails runner -e production 'p "test"'
/usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:20:in `initialize': Connection refused - "/tmp/spring/6e31dd16c1146fc209ac385f36aac9a1" (Errno::ECONNREFUSED)
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:20:in `open'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:20:in `server'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:54:in `verify_server_version'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/run.rb:25:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/rails.rb:23:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client/command.rb:7:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/client.rb:26:in `run'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/bin/spring:48:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p481/gems/spring-1.1.3/lib/spring/binstub.rb:11:in `<top (required)>'
from /usr/local/rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p481/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /s/usr-local/www/the_project/releases/20140724133941/bin/spring:16:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
到目前为止,我验证了相应的文件是否/tmp/spring
按预期存在。
此错误的原因可能是什么?如何实现正常工作的 Spring?
更新 1
这是我到目前为止所做的几项检查的概述。
# ls -al /tmp/spring
total 32
drwxr-xr-x 2 proj wheel 8 Jul 27 19:35 .
drwxrwxrwt 36 root wheel 43 Jul 28 08:22 ..
srwxr-xr-x 1 proj wheel 0 Jul 27 19:35 3004493e4fa38d91e78f82a2e74b4bc8
-rw-r--r-- 1 proj wheel 6 Jul 27 19:35 3004493e4fa38d91e78f82a2e74b4bc8.pid
srwxr-xr-x 1 proj wheel 0 Jun 30 13:00 383a7b299457953fc0eda45a4eca65f8
-rw-r--r-- 1 proj wheel 5 Jun 30 13:00 383a7b299457953fc0eda45a4eca65f8.pid
srwxr-xr-x 1 proj wheel 0 Jul 24 14:01 6e31dd16c1146fc209ac385f36aac9a1
-rw-r--r-- 1 proj wheel 6 Jul 24 14:01 6e31dd16c1146fc209ac385f36aac9a1.pid
# groups proj
proj wheel rvm
# bin/spring status
Spring is running:
25240 ruby: spring server | 20140727193408 | started 14 hours ago (ruby)
25245 ruby: spring app | 20140727193408 | started 0 secs ago | production mode (ruby)
# fuser /tmp/spring/*
/tmp/spring/3004493e4fa38d91e78f82a2e74b4bc8:
/tmp/spring/3004493e4fa38d91e78f82a2e74b4bc8.pid: 25240wa
/tmp/spring/383a7b299457953fc0eda45a4eca65f8:
/tmp/spring/383a7b299457953fc0eda45a4eca65f8.pid:
/tmp/spring/6e31dd16c1146fc209ac385f36aac9a1:
/tmp/spring/6e31dd16c1146fc209ac385f36aac9a1.pid: 17260wa
# ps aux | grep -E '25240|17260'
proj 17260 0.0 0.1 79040 3544 - IJ Thu02PM 0:00.47 ruby: spring server | 20140724133941 | started 92 hours ago (ruby)
proj 25240 0.0 0.1 79040 3372 - IJ 7:35PM 0:00.28 ruby: spring server | 20140727193408 | started 14 hours ago (ruby)
# head -n1 /tmp/spring.log
[2014-07-28 10:16:40 +0000] [66008] [server] started on /tmp/spring/3004493e4fa38d91e78f82a2e74b4bc8
# tail /tmp/spring.log
[2014-07-28 10:18:00 +0000] [66008] [server] accepted client
[2014-07-28 10:18:00 +0000] [66008] [server] running command rails_runner
[2014-07-28 10:18:00 +0000] [66128] [application:production] got client
[2014-07-28 10:18:00 +0000] [66128] [application:production] forked 66370
[2014-07-28 10:18:00 +0000] [66008] [application_manager:production] got worker pid 66370
[2014-07-28 10:18:03 +0000] [66128] [application:production] 66370 exited with 0