Sono abbastanza nuovo per bash scripting, ma mi sento come se mi mancasse davvero qualcosa di base qui. Sto cercando di una versione modificata del malapena Mike Perham's upstart sidekiq script su una macchina Ubuntu 14.04, ma quasi nulla è in corso di valutazione come previsto:Gli script upstart o bash sono cambiati su Ubuntu 14.04? (Cercando di avviare sidekiq con upstart)
- esportazione non sembra funzionare
- fonte non sembra per valutare la mia variabile PATH cambiato nel .bashrc o eseguendo il comando rbenv init
- cd non sembra cambiare le directory, a meno che il comando $ (pWD) non è il modo corretto per valutarlo
Ecco la mia script modificato:
# /etc/init/sidekiq.conf - Sidekiq config
# This example config should work with Ubuntu 12.04+. It
# allows you to manage multiple Sidekiq instances with
# Upstart, Ubuntu's native service management tool.
# change to match your deployment user
setuid deploy
setgid deploy
stop on (stopping workers or runlevel [06])
respawn
respawn limit 3 30
instance $index
script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rbenv
exec /bin/bash <<EOT
# use syslog for logging
# exec &> /dev/kmsg
# pull in system rbenv
export HOME=/home/deploy
echo "home is $HOME"
source /home/deploy/.bashrc
echo "path is $PATH"
cd /home/deploy/domain_freek/current
echo "user is $(whoami) and pwd is $(pwd) and rbenv is located at $(which rbenv)"
exec bundle exec sidekiq -i ${index} -e production
EOT
end script
ecco l'output ottengo nel file di registro parvenu:
home is
path is /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
user is deploy and pwd is/and rbenv is located at
/bin/bash: line 12: exec: bundle: not found
Provare 'exec/bin/bash << 'EOT'' (virgolette sull'indicatore). L'output dovrebbe avere più senso. – Mat
OK! Grazie, le virgolette sono state d'aiuto. Ora HOME viene esportato e cd cambia effettivamente la directory ... Ora devo solo capire come caricare correttamente il file .bashrc, o inizializzare rbenv in un altro modo – Josh