My shell script knowledge is a little shaky, but I want to run a daemon (Ubuntu 14.04) defined in /etc/init.d/unicorn, like so
case "$1" in start) check_config check_app_root log_daemon_msg "Starting $DESC" $NAME || true if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS; then
In a separate file, /etc/default/unicorn, I have the below variables defined:
APP_ROOT=/home/rails/myproject ... UNICORN_OPTS="-D -c $CONFIG_RB -E $RAILS_ENV" ... DAEMON="cd $APP_ROOT; $GEM_HOME/bin/bundle exec $GEM_PATH/bin/unicorn"
I added "cd $APP_ROOT" because that's the directory from where "$GEM_HOME/bin/bundle" must run. However, when I go to start my service, I get the below error:
myuser@myproject:~$ sudo service unicorn restart /home/rails/.gem/bin/bundle * Restarting Unicorn web server unicorn start-stop-daemon: unable to stat //cd (No such file or directory)
Is there some other way I can store my options so that I can run my command from the desired directory?