我寫了一個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