I am trying to start a New Relic monitoring plugin MeetMe/newrelic_plugin_agent
with upstart on Ubuntu 12.04. Here is the script I wrote:
env USER=newrelic
env DAEMON="/usr/local/bin/newrelic_plugin_agent"
env DAEMONARGS=" -c /etc/newrelic/newrelic_plugin_agent.cfg"
start on startup
stop on shutdown
exec start-stop-daemon --start --chuid $USER --exec $DAEMON --$DAEMONARGS
The following error is written to the corresponding upstart log: Error starting /usr/local/bin/newrelic_plugin_agent: Cannot write to specified pid file path /var/run/newrelic/newrelic_plugin_agent.pid
If I add --make-pidfile --pidfile /var/run/newrelic/newrelic_plugin_agent.pid
parameters to start-stop-daemon
:
exec start-stop-daemon --start --make-pidfile --pidfile
/var/run/newrelic/newrelic_plugin_agent.pid --chuid $USER
--exec $DAEMON --$DAEMONARGS
the log contains start-stop-daemon: unable to open pidfile '/var/run/newrelic/newrelic_plugin_agent.pid' for writing (No such file or directory)
.
/var/run/newrelic/
folder exists and is owned by newrelic
user and is assigned to new relic
group.
How do I write the upstart script, so that the newrelic_plugin_agent is started in boot?
I have not managed to start the New Relic plugin by using upstart, but there was a much simpler way to have it startet on boot. The Plugin also contains init.d scripts for RedHat and Ubuntu (here). So just
/opt/newrelic_plugin_agent/newrelic_plugin_agent.deb
in /etc/init.d
folder: cp /opt/newrelic_plugin_agent/newrelic_plugin_agent.deb /etc/init.d/newrelic_plugin_agent
sudo chmod a+x /etc/init.d/newrelic_plugin_agent
update-rc.d newrelic_plugin_agent defaults
/etc/init.d/newrelic_plugin_agent start