Im usando Monit per monitorare uno script Ruby che utilizza Ruby daemons gem, che lancia un processo separato con PID - seguendo le istruzioni da Monitor ruby processes with Monitmonitoraggio di script Ruby, usando Monit - Compreso RVM
Al fine di eseguire lo script ruby ho bisogno per includere RVM nelle stringhe Monit start
e stop
, così ho accesso a tutte le gemme.
Tuttavia quando .monitrc
esegue ottengo il seguente errore:
$rvm_path (/usr/local/rvm) does not exist./home/william/.rvm/scripts/rvm: line 174: rvm_is_a_shell_function: command not found
/home/william/.rvm/scripts/rvm: line 185: __rvm_teardown: command not found
'myserver_1' failed to start
Aborting event
ho aggiunto PATH=$PATH:/home/william/.rvm/bin && . /home/william/.rvm/scripts/rvm
alle stringhe di comando start
e stop
per cercare di includere RVM. Tuttavia ancora non funziona
file di configurazione .monitrc
:
....
check process myserver_1
with pidfile /home/william/ruby/barclays/myapp.rb.pid
start = "/bin/bash -c 'PATH=$PATH:/home/william/.rvm/bin && . /home/william/.rvm/scripts/rvm && ruby /home/william/ruby/barclays/daemonloader.rb start'"
stop = "/bin/bash -c 'PATH=$PATH:/home/william/.rvm/bin && . /home/william/.rvm/scripts/rvm && ruby /home/william/ruby/barclays/daemonloader.rb stop'"
....
Grazie per il vostro aiuto.
EDIT
Ive ha ottenuto la sensazione che il problema è legato alle variabili di ambiente. Citando this page
You should also know that for security reasons Monit purges the environment and only sets a spartan PATH variable that contains /bin, /usr/bin, /sbin and /usr/sbin. If your program or script dies, the reason could be that it expects certain environment variables or to find certain programs via PATH. If this is the case you should set the environment variables you need directly in the start or stop script called by monit.
Finally, Monit uses the system call execv to execute a program or a script. This means that you cannot write shell commands directly in the start, stop or exec statements. To do this, you must do as above; start a shell and issue your commands there. For example:
start program = "/bin/bash -c 'my shell command && my other command'"
Ho provato questo: 'start =" /home/william/.rvm/bin/rvm in/home/william/ruby / project do ruby daemonloader.rb start "'. Purtroppo ora ricevo il messaggio di errore "Impossibile trovare rvm install!" e fallisce. Cosa fa 'xxxx in yyy do zzz'? Potresti spiegare la risposta un po '? Grazie. – Imme22009
stai eseguendo questo come 'william' utente? – mpapis
Sì - Utente: william. – Imme22009