Need help to write upstart script for newrelic plugin
James Hunt
james.hunt at ubuntu.com
Thu Feb 6 14:21:33 UTC 2014
On 06/02/14 13:52, Mariano González wrote:
> James, I've tried to insert debug and procenv in my pre-start script, none of
> them created any .log file in /tmp/
>
> First:
>
> start on..
> stop on..
>
> script
>
> echo "DEBUG: `set`" >> /tmp/myjob.log
>
> end script
>
> respawn
> chdir /opt/turner/services/newrelic/newrelic_rs_dfw
> exec bundle exec ./bin/newrelic_rs
>
> The service respawned 10 times and then got killed.
>
> Second:
>
> start on..
> stop on..
>
> script
> exec procenv --file=/tmp/procenv-job.log --exec -- bundle exec ./bin/newrelic_rs
> end script
You don't need the script/end script stanzas - just specify the following in the
job:
exec procenv --file=/tmp/procenv-job.log --exec -- bundle exec ./bin/newrelic_rs
Please check that your job is valid using:
$ init-checkconf /etc/init/newrelic.conf
... then start the job manually and look for the logs:
$ sudo start newrelic
If no joy, feel free to join the #upstart irc channel on freenode to discuss
further.
>
> respawn
> chdir /opt/turner/services/newrelic/newrelic_rs_dfw
> exec bundle exec ./bin/newrelic_rs
>
> Again got respawned and killed. No .log file in /tmp.
>
> I think I'm doing something wrong but cannot find it out.
>
> Thanks and sorry for the dumbness, I'm just starting with upstart scripts.
>
>
>
>
> On 6 February 2014 10:21, James Hunt <james.hunt at ubuntu.com
> <mailto:james.hunt at ubuntu.com>> wrote:
>
> 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>
> > <mailto: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>
> <mailto: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
>
>
>
>
> --
> 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