我使用的是提供的init.d腳本(init.d script from the sidekiq github repo),但是我在安裝了系統RVM的Ubuntu系統上。使用RVM管理使用init.d腳本的sidekiq
我似乎無法弄清楚如何進入我的應用程序目錄,併發出命令,而不會有一些抱怨日誌中沒有實際開始。
問題:當我使用RVM時,sidekiq的啓動命令應該如何在我的init.d腳本中看起來像?我的用戶名爲ubuntu。目前我有這在我的init.d腳本:
START_CMD="$BUNDLE exec $SIDEKIQ"
# where bundle is /usr/local/rvm/gems/ruby-1.9.3-p385/bin/bundle
# and sidekiq is sidekiq
# I've also tried with the following args: -e $APP_ENV -P $PID_FILE -C $APP_CONFIG/sidekiq.yml -d -L $LOG_FILE"
RETVAL=0
start() {
status
if [ $? -eq 1 ]; then
[ `id -u` == '0' ] || (echo "$SIDEKIQ runs as root only .."; exit 5)
[ -d $APP_DIR ] || (echo "$APP_DIR not found!.. Exiting"; exit 6)
cd $APP_DIR
echo "Starting $SIDEKIQ message processor .. "
echo "in dir `pwd`"
su - ubuntu -c "$START_CMD >> $LOG_FILE 2>&1 &"
RETVAL=$?
#Sleeping for 8 seconds for process to be precisely visible in process table - See status()
sleep 8
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
return $RETVAL
else
echo "$SIDEKIQ message processor is already running .. "
fi
}
我sidekiq.log給了我這個錯誤:Could not locate Gemfile
。但是,根據執行此命令時的echo pwd,我打印了工作目錄,並且我絕對是在我應用程序的當前目錄中。
當我拿出蘇 - [這裏指揮] Ubuntu的-c,我得到這個錯誤:
/usr/bin/env: ruby_noexec_wrapper: No such file or directory
我的解決方法就是手動啓動的過程。當我手動cd到我的應用程序目錄,併發出以下命令:
bundle exec sidekiq -d -L log/sidekiq.log -P tmp/pids/sidekiq.pid
事情按計劃進行,然後
sudo /etc/init.d/sidekiq status
告訴我的事情是啓動和運行。
此外,sudo /etc/init.d/sidekiq停止和狀態按預期工作。
在/usr/local/rvm/wrappers/ruby-1.9.3-p385目錄中,沒有捆綁命令。 '哪個bundle給了我/usr/local/rvm/gems/ruby-1.9.3-p385/bin/bundle。另外,我是否需要su - ubuntu -c [命令]代碼? – Danny
還添加了指令,如果不可用,則生成包裝 – mpapis