Need help to write upstart script for newrelic plugin

James Hunt james.hunt at ubuntu.com
Thu Feb 6 13:21:53 UTC 2014


On 06/02/14 12:12, Mariano González wrote:
> Thanks Clint! 
> 
> I've edited the .conf file to: https://gist.github.com/Mariano-gon/8842908
> 
> From messages.log: https://gist.github.com/Mariano-gon/8842922
> 
> And newrelic agent never starts. 
Firstly, http://upstart.ubuntu.com/cookbook/#respawn - my advice would be to
drop respawn until you have the job atleast starting and stopping normally.

Has any output been logged to /var/log/upstart/newrelic.log?

> This plugin/agent needs to be run (bundle exec ./bin/newrelic_rs) inside
> /path_installation/newrelic_rs_dfw/ (I think that's because it is where the
> right gem is installed). So, my guess would be that initctl is not relocating
> itself in /path_installation/newrelic_rs_dfw/ to run the budle exec and that's
> why it's falling to start. Could it be?
The most likely problem is that newrelic needs certain environment variables set
that are not set by default; in terms of standard environment variables, Upstart
will only set TERM and PATH. If you want to set others, use the env stanza:

http://upstart.ubuntu.com/cookbook/#env

To help track down why your service is not starting:

http://upstart.ubuntu.com/cookbook/#see-the-environment-a-job-runs-in
http://upstart.ubuntu.com/cookbook/#checking-how-a-service-might-react-when-run-as-a-job

This link shows you how to diff the environment that newrelic *does* run in
versus the environment provided by upstart:

http://upstart.ubuntu.com/cookbook/#determining-why-your-service-fails-to-start

If you use procenv, look at the 'current directory (cwd):' output too which will
correspond to what you specified for the chdir stanza in the job configuration.

> 
> Thanks!
> 
> 
> 
> 
> On 6 February 2014 03:26, Clint Byrum <clint at ubuntu.com
> <mailto:clint at ubuntu.com>> wrote:
> 
>     Excerpts from Mariano González's message of 2014-02-05 09:55:59 -0800:
>     > Hi there.
>     >
>     > I'm trying to monitor a newrelic plugin service with upstart in CentOS 6.x.
>     >
>     > Here's newrelic plugin script: https://gist.github.com/Mariano-gon/8829482
>     >
>     > Here's my upstart script: https://gist.github.com/Mariano-gon/8827034
>     >
>     > When I try to restart it, it'll respawn x times and then stops itself.
>     >
>     > Here're the log lines: https://gist.github.com/Mariano-gon/8829533
>     >
> 
>     https://gist.github.com/Mariano-gon/8827034#file-newrelic_rs-conf-L7
> 
>     exec means you will never reach the next line. There is a declarative
>     way to change dirs, so you don't need the script stanza at all:
> 
>     ---
>     respawn
>     chdir /path/to/plugin_installation
>     exec bundle exec ./bin/newrelic_rs
>     ---
> 
>     Note that if you want it to start at boot, don't use any of the weird
>     compound start ons you see:
> 
>     start on runlevel [2345]
>     stop on runlevel [016]
> 
>     Those two should be fine.
> 
>     --
>     upstart-devel mailing list
>     upstart-devel at lists.ubuntu.com <mailto:upstart-devel at lists.ubuntu.com>
>     Modify settings or unsubscribe at:
>     https://lists.ubuntu.com/mailman/listinfo/upstart-devel
> 
> 
> 
> 
> -- 
> Mariano Gabriel González
> 
> 

Kind regards,

James.
--
James Hunt
____________________________________
#upstart on freenode
http://upstart.ubuntu.com/cookbook
https://lists.ubuntu.com/mailman/listinfo/upstart-devel



More information about the upstart-devel mailing list