Monitoring Ruby script using Monit - including RVM

Im using Monit to monitor a ruby ​​script that uses a gem gb driver that starts a separate process with PID - following the instructions from Monitoring ruby ​​processes with Monit

To execute the ruby ​​script, I need to include RVM in the Monit lines startand stoptherefore I have access to all the gems.

However, when executed .monitrc, I get the following error:

$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

I added PATH=$PATH:/home/william/.rvm/bin && . /home/william/.rvm/scripts/rvmto the command lines startand stopto try to enable RVM. However, this still does not work.

Configuration file .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'"

  ....

Thank you for your help.

EDIT

, .

, Monit PATH, /bin, /usr/bin,/sbin /usr/sbin. script , , PATH. , , script monit.

, Monit execv script. , start, stop exec. , , ; . :

start program = "/bin/ bash -c ' && my "

+5
2

:

/path/to/rvm/bin/rvm in /path/to/project do ...

rvm project ... / - :

/usr/bin/env "HOME=/home/william rvm_path=/home/william/.rvm 
  /home/william/.rvm/bin/rvm in /home/william/ruby/project do
  ruby daemonloader.rb start"

RVM, cd , ruby ​​ ruby ​​ .

+3

- Monit.

start = "/bin/su - william -c 'cd /home/william/ruby/project && ~/.rvm/bin/rvm default do bundle exec ruby daemonloader.rb start'"

.

0

All Articles