Can't cd Within Init.d Script
-
21-12-2019 - |
Question
I'm at an impasse and need help. Implementing a Unicorn init script that throws an error when it tries to change working directory to my application path (in order to execute 'bundle exec unicorn').
Capistrano output is as follows.
DEBUG [50572a40] Starting Unicorn Daemon for accreu
DEBUG [50572a40] Starting Unicorn Daemon for accreu
DEBUG [50572a40] /etc/init.d/unicorn_accreu: 44: cd:
DEBUG [50572a40] Starting Unicorn Daemon for accreu
DEBUG [50572a40] can't cd to /home/ubuntu/apps/accreu;
DEBUG [50572a40] Starting Unicorn Daemon for accreu
DEBUG [50572a40]
DEBUG [50572a40] cd /home/ubuntu/apps/accreu; bundle exec unicorn -D -c config/unicorn.rb -E production
DEBUG [50572a40]
DEBUG [50572a40] /home/ubuntu
The relevant init lines are:
UNICORN_OPTS="-D -c <%= fetch(:unicorn_config) %> -E production"
CMD="cd <%= fetch(:prime_path) %>; bundle exec unicorn $UNICORN_OPTS"
Solution
The solution was to add 'host: localhost' within my production database.yml file.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow