簡體   English   中英

使用RVM使用init.d腳本管理sidekiq

[英]Manage sidekiq with init.d script using RVM

我正在使用提供的init.d腳本(來自sidekiq github repoinit.d腳本 ),但是我在ubuntu系統中,RVM安裝在整個系統范圍內。

我似乎無法弄清楚如何使用cd進入我的應用程序目錄並發出命令,而日志中沒有任何抱怨,也沒有任何實際啟動。

問題 :使用RVM時,在我的init.d腳本中,sidekiq的啟動命令應該是什么樣的? 我的用戶名為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 但是,根據回顯pwd,在執行此命令時,我將打印工作目錄,並且絕對可以將其保存在應用程序的當前目錄中。

當我取出su-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停止運行並狀態按預期運行。

幾個月前,我寫了一篇博客文章,介紹了我為Sidekiq編寫init.d腳本的經驗,但是我使用的是rbenv而不是RVM。

https://cdyer.co.uk/blog/init-script-for-sidekiq-with-rbenv/

我認為您應該能夠使用幾乎相同的功能,除了修改用戶名和應用程序目錄變量。

使用包裝器:

BUNDLER=/usr/local/rvm/wrappers/ruby-1.9.3-p385/bundle

如果沒有打包程序包裝器,請使用以下命令生成它:

rvm wrapper ruby-1.9.3-p385 --no-links bundle # OR:
rvm wrapper ruby-1.9.3-p385 --no-links --all

您可以使用別名使其更容易:

rvm alias create my_app 1.9.3-p385

然后像這樣使用它:

BUNDLER=/usr/local/rvm/wrappers/my_app/bundle

這樣,當應用程序ruby更改時,您不必更改腳本-只需更新別名,在rvm-capistrano => https://github.com/wayneeseguin/rvm-capistrano/#中對此有很好的描述/集成創建應用程序的別名和包裝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM