我写了一个bash脚本来为两个项目启动瘦服务器。Bash脚本不能在启动时运行
#! /bin/sh
cd /path/to/my/project_1
thin -e production -p 3000 --daemonize -s 10 start
然后将它放在/etc/init.d/start_thin中。给它755的权限。冉:
sudo update-rc.d start_thin defaults.
然后
sudo reboot
薄未启动。谢谢。
UPDATE:
一个长期的斗争之后,我发现这个错误,只有开始时细跟/etc/init.d/thin情况:
写作PID到TMP /的PID/thin.3000.pid 使用Rails适配器/path/.rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG]细分故障红宝石1.8.7(2010-08-16 patchlevel 302) [i686的Linux的]
我想现在唯一合乎逻辑的做法是切换到 “正常” 的SQL宝石。
更新2:
我发现this resource这之前帮我,但现在不能帮助。
更新3:
我重新安装RVM使用quick install。现在当启动脚本运行时,我在日志中看到缺少一个gem:multi_json-1.1.0。我安装它并放入Gemfile。没有帮助。不过,当我手动执行bash脚本时 - 没有问题。只有在启动时,它抱怨multi_json-1.1.0。
UPDATE 4:
只有在启动时,薄的日志文件中包含:
我不明白为什么它使用1.8的宝石,当我有红宝石1.9.2安装: - ?
>> Writing PID to tmp/pids/thin.3000.pid
>> Using rails adapter
>> Exiting!
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:87:in `materialize': Could not find multi_json-1.1.0 in any of the sources (Bundler::GemNotFound)
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:81:in `map!'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/spec_set.rb:81:in `materialize'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/definition.rb:90:in `specs'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/definition.rb:135:in `specs_for'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/definition.rb:124:in `requested_specs'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/environment.rb:23:in `requested_specs'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/runtime.rb:11:in `setup'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler.rb:107:in `setup'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.15/lib/bundler/setup.rb:17
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /home/user1/myproj1/config/boot.rb:6
from /home/user1/myproj1/config/application.rb:1:in `require'
from /home/user1/myproj1/config/application.rb:1
from /home/user1/myproj1/config/environment.rb:2:in `require'
from /home/user1/myproj1/config/environment.rb:2
from /usr/lib/ruby/1.8/rack/adapter/rails.rb:42:in `require'
from /usr/lib/ruby/1.8/rack/adapter/rails.rb:42:in `load_application'
from /usr/lib/ruby/1.8/rack/adapter/rails.rb:23:in `initialize'
from /usr/lib/ruby/1.8/rack/adapter/loader.rb:36:in `new'
from /usr/lib/ruby/1.8/rack/adapter/loader.rb:36:in `for'
from /usr/lib/ruby/1.8/thin/controllers/controller.rb:163:in `load_adapter'
from /usr/lib/ruby/1.8/thin/controllers/controller.rb:67:in `start'
from /usr/lib/ruby/1.8/thin/runner.rb:174:in `send'
from /usr/lib/ruby/1.8/thin/runner.rb:174:in `run_command'
from /usr/lib/ruby/1.8/thin/runner.rb:140:in `run!'
from /usr/bin/thin:6
因此,自然,我安装了multi_json gem,然后,bundle install,以及,您怎么看?同样的老问题:)。
如果它位于该目录中,请尝试'。/ thin'。很有可能它不在PATH中。 – 2012-03-21 17:35:29
谢谢,我试过了,再次尝试给出完整路径。没有运气。 – valk 2012-03-21 17:44:15
一个问题是,cd在子shell中运行。但问题在于开始瘦身。我检查了日志,并且都看起来不错。所以它必须是其他问题。目前我用thin -c/path/to/my/project_1 -e生产启动它-p 3000 --daemonize -s 10 start – valk 2012-03-21 19:10:57