1

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?

silentser
  • 2,083
  • 2
  • 23
  • 29
  • With upstart you don't have to use things like `start-stop-daemon`. Just set `exec` to start the process and upstart takes care of the rest. – Biffen Apr 11 '14 at 21:18
  • The same problem if using exec. But I found a solution (see below) – silentser Apr 13 '14 at 08:13

1 Answers1

1

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

  1. Copy /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
  2. Make the copied script executable: sudo chmod a+x /etc/init.d/newrelic_plugin_agent
  3. Configure this script to run on system boot: update-rc.d newrelic_plugin_agent defaults
  4. Start the script: /etc/init.d/newrelic_plugin_agent start
silentser
  • 2,083
  • 2
  • 23
  • 29
  • 1
    A symlink instead of a copy will make an upgrade easier. – Biffen Apr 13 '14 at 08:36
  • I am not quite sure it will completely solve the problem - the original init.d script is not executable and one cannot run chmod on a symlinc. The update will overwrite the original script making it non-executable and the symlink will stop working. – silentser Apr 14 '14 at 08:29
  • 1
    Hm, OK. Of course the original script *should* be executable if things were done right. But then again the installer *should* take care of everything for you. File a bug with the vendor! – Biffen Apr 14 '14 at 08:35