【发布时间】:2013-08-03 23:07:07
【问题描述】:
我正在使用提供的 init.d 脚本(init.d script from the sidekiq github repo),但我在一个安装了 RVM 的 ubuntu 系统上。
我似乎无法弄清楚如何 cd 进入我的应用程序目录并发出命令,而不会在日志中出现一些抱怨并且实际上什么都没有启动。
问题:当我使用 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,在执行此命令时,我绝对是在我的应用程序的当前目录中。
当我取出 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 stop 和 status 按预期工作。
【问题讨论】:
标签: ruby-on-rails ubuntu rvm sidekiq