I've done an init.d script in order to start a newrelic plugin as daemon. The problem is that when I run service rb_nr_agent start
it has some errors related with "require". Output:
[root@device newrelic_rb_plugin]# /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- snmp (LoadError)
from /usr/local/rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/newrelic_rb_plugin/newrelic_redborder_agent:5:in `<main>'
[root@device newrelic_rb_plugin]# ./rb_nr_agent start Starting rb_nr_agent:[ OK ]
It doesn't start properly. When I run the same script but in the root path of the project it doesn't have any error and it works fine. The init.d is a copy of that one. Here you have the start option of the script:
start() {
RESULT=`ps aux | grep $executable | grep -c -v grep`
if [ "${RESULT:-null}" -ge "1" ]; then
echo "$prog is currently running"
else
echo -n "Starting $prog: "
/opt/newrelic_rb_plugin/newrelic_redborder_agent > /dev/null &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo_success
else
echo_failure; failure
RETVAL=1
fi
echo
fi
return $RETVAL }