Trying to write an upstart script for a newrelic agent

Mariano González gonzalez.mariano.gabriel at gmail.com
Tue Feb 18 19:17:16 UTC 2014


Steve

Tried what you suggested, newrelic_rs_dfw_test.conf:

# Upstart script

start on runlevel [2345]
stop on runlevel [016]

respawn

chdir /opt/turner/services/newrelic/newrelic_rs_dfw/

exec bundle exec bin/newrelic_rs

----

/var/log/messages

Feb 18 19:07:50  init: newrelic_rs_dfw_test main process (5149) terminated
with status 1
Feb 18 19:07:50  init: newrelic_rs_dfw_test respawning too fast, stopped
Feb 18 19:07:50  init: newrelic_rs_dfw_test goal changed from start to stop
Feb 18 19:07:50  init: newrelic_rs_dfw_test state changed from running to
stopping
Feb 18 19:07:50  init: Handling stopping event
Feb 18 19:07:50  init: newrelic_rs_dfw_test state changed from stopping to
killed
Feb 18 19:07:50  init: newrelic_rs_dfw_test state changed from killed to
post-stop
Feb 18 19:07:50  init: newrelic_rs_dfw_test state changed from post-stop to
waiting
Feb 18 19:07:50  init: Handling stopped event

----

init (upstart 0.6.5)

----

Run the bundle from the right folder:

[root at server newrelic_rs_dfw]# pwd
/path/newrelic/newrelic_rs_dfw
[root at server newrelic_rs_dfw]# bundle exec ./bin/newrelic_rs
[Tue Feb 18 19:13:23 UTC 2014] WARN: SSL is disabled by default when using
Ruby 1.8.x

And started normally.

----

Tried not being root, and got a gem error:

-sh-4.1$ bundle exec ./bin/newrelic_rs
Could not find rake-10.1.1 in any of the sources
Run `bundle install` to install missing gems.

It does work with sudo.
--





On 18 February 2014 16:01, Steve Langasek <steve.langasek at ubuntu.com> wrote:

> On Tue, Feb 18, 2014 at 08:56:37AM -0300, Mariano González wrote:
> > Hi Steve and Clint. Thanks for your comments.
>
> > You're totally right, it's not necessary to write sudo -u root as it's
> the
> > same as writing sudo. My fault there.
> > But, the command to run the agent is the following:
>
> > $ cd /path/newrelic_rs_dfw/
> > $ bundle exec ./bin/newrelic_rs
>
> upstart has a 'chdir' primitive you can use for this.
>
> chdir /path/newrelic_rs_dfw
> exec ./bundle exec ./bin/newrelic_rs
>
> (I'm assuming that 'bundle' is in the local directory, and not something on
> the system path.)
>
> > As bundle exec is a ruby gem located in /path/newrelic_rs_dfw/. So, to
> this
> > script to function it'd need to locate in /path/newrelic_rs_dfw/ first
> and
> > then run the bundle exec. Which it doesn't do if I write down those two
> > previous steps in a script. Neither it does if I specify an env variable
> or
> > source stanza. That's why I think this is an env issue.
>
> What env variable would you expect to be setting here?  That's the wrong
> tool for changing the directory.
>
> > Finally, there's no trace of newrelic logs in /var/log/ besides
> /newrelic/
> > folder where OTHER newrelic agents does write their logs in this vm.
>
> What version of upstart are you using?
>
>
> --
> Steve Langasek                   Give me a lever long enough and a Free OS
> Debian Developer                   to set it on, and I can move the world.
> Ubuntu Developer                                    http://www.debian.org/
> slangasek at ubuntu.com                                     vorlon at debian.org
>



-- 
Mariano Gabriel González
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/upstart-devel/attachments/20140218/8fbcee47/attachment-0001.html>


More information about the upstart-devel mailing list