Orbited as a daemon with upstart

15 views
Skip to first unread message

davebath

unread,
Oct 18, 2009, 7:52:15 AM10/18/09
to Orbited Discussion
Hi all,

Apologies in advance if I've missed a previous answer to this
question, but I am experiencing some strange behaviour when attempting
to run Orbited through upstart.

Setup:

Ubuntu 8.04 (Hardy) LTS
Orbited 0.7.10

Problem:

Following the example at http://orbited.org/wiki/Deployment, I added a
new file in /etc/event.d/orbited as follows:

start on startup
exec /usr/bin/orbited --config=/etc/orbited.cfg

Initially following the example exactly, orbited wouldnt start at all
(sudo start orbited). I then spotted in the code that there's an
explicit check on POSIX systems to prevent running as root.

I then added a user and group to my orbited.cfg and orbited started.
However, upstart never exited cleanly (i.e. sudo start orbited spat
out the usual startup sequence but did not return me to the shell).
Orbited did appear to be started though.

In a problem that may be related, logging seems to be behaving
strangely. If I delete the log files, and restart orbited (sudo stop
orbited, sudo start orbited) then I get 4 entries in info.log:

10/17/09 11:22:58:362 INFO orbited.start proxy protocol active
10/17/09 11:22:58:363 INFO orbited.start Listening http@9000
10/17/09 11:22:58:363 INFO orbited.start Listening stomp@61613
10/17/09 11:22:58:372 INFO orbited.start switching to user
orbited (uid=xxx) and group adm (gid=x)

and the log files are written as user/group root. After that I get
absolutely nothign in any log file. However, when I stop orbited
again, warn and access suddenly fill up with entries!

It's almost as if whilst the daemon is runnign as another user the
logging is being suspended. I was wondering if this may be related to
upstart not returning when orbited is started?

Any help much appreciated.

Best,

Dave





Jérémy Lal

unread,
Oct 18, 2009, 8:31:31 AM10/18/09
to orbite...@googlegroups.com
On 18/10/2009 13:52, davebath wrote:
>
> Hi all,
>
> Apologies in advance if I've missed a previous answer to this
> question, but I am experiencing some strange behaviour when attempting
> to run Orbited through upstart.
>
> Setup:
>
> Ubuntu 8.04 (Hardy) LTS
> Orbited 0.7.10
>
> Problem:
>
> Following the example at http://orbited.org/wiki/Deployment, I added a
> new file in /etc/event.d/orbited as follows:
>
> start on startup
> exec /usr/bin/orbited --config=/etc/orbited.cfg
>
> Initially following the example exactly, orbited wouldnt start at all
> (sudo start orbited). I then spotted in the code that there's an
> explicit check on POSIX systems to prevent running as root.
>
> I then added a user and group to my orbited.cfg and orbited started.
> However, upstart never exited cleanly (i.e. sudo start orbited spat
> out the usual startup sequence but did not return me to the shell).
> Orbited did appear to be started though.
It does not exit because orbited does not return.
Since orbited is using twisted, it should really be using a .tac file,
which allows twistd to launch it as a daemon cleanly.

On debian (with init scripts) i'm using the attached script.
Which is not for upstart, but could help you finding the right way.


>
> In a problem that may be related, logging seems to be behaving
> strangely. If I delete the log files, and restart orbited (sudo stop
> orbited, sudo start orbited) then I get 4 entries in info.log:
>
> 10/17/09 11:22:58:362 INFO orbited.start proxy protocol active
> 10/17/09 11:22:58:363 INFO orbited.start Listening http@9000
> 10/17/09 11:22:58:363 INFO orbited.start Listening stomp@61613
> 10/17/09 11:22:58:372 INFO orbited.start switching to user
> orbited (uid=xxx) and group adm (gid=x)
>
> and the log files are written as user/group root. After that I get
> absolutely nothign in any log file. However, when I stop orbited
> again, warn and access suddenly fill up with entries!
>
> It's almost as if whilst the daemon is runnign as another user the
> logging is being suspended. I was wondering if this may be related to
> upstart not returning when orbited is started?

I don't think it's related at all to your previous problems.
It seems the logging facility is buffering output.

Regards,
Jérémy Lal


python-orbited.init.d
signature.asc

davebath

unread,
Oct 18, 2009, 8:54:57 AM10/18/09
to Orbited Discussion
Jérémy, many thanks for the swift reply.

On Oct 18, 1:31 pm, "Jérémy Lal" <holi...@gmail.com> wrote:
> On 18/10/2009 13:52, davebath wrote:
>
>
>
> > Hi all,
>
> > Apologies in advance if I've missed a previous answer to this
> > question, but I am experiencing some strange behaviour when attempting
> > to run Orbited through upstart.
>
> > Setup:
>
> > Ubuntu 8.04 (Hardy) LTS
> > Orbited 0.7.10
>
> > Problem:
>
> > Following the example athttp://orbited.org/wiki/Deployment, I added a
> > new file in /etc/event.d/orbited as follows:
>
> > start on startup
> > exec /usr/bin/orbited --config=/etc/orbited.cfg
>
> > Initially following the example exactly, orbited wouldnt start at all
> > (sudo start orbited).  I then spotted in the code that there's an
> > explicit check on POSIX systems to prevent running as root.
>
> > I then added a user and group to my orbited.cfg and orbited started.
> > However, upstart never exited cleanly (i.e. sudo start orbited spat
> > out the usual startup sequence but did not return me to the shell).
> > Orbited did appear to be started though.
>
> It does not exit because orbited does not return.
> Since orbited is using twisted, it should really be using a .tac file,
> which allows twistd to launch it as a daemon cleanly.
>
> On debian (with init scripts) i'm using the attached script.
> Which is not for upstart, but could help you finding the right way.
>
>

Ok, I didnt' realize it didn't return. It seems that the deployment
advice on the orbited website is not 100% straightforwards then. Your
script is very thorough (thank you!), but I agree perhaps the sensible
approach is to build a .tac and launch it as a daemon with twistd,
rather than having to do so much behind the scenes work.

>
>
> > In a problem that may be related, logging seems to be behaving
> > strangely.  If I delete the log files, and restart orbited (sudo stop
> > orbited, sudo start orbited) then I get 4 entries in info.log:
>
> > 10/17/09 11:22:58:362 INFO   orbited.start      proxy protocol active
> > 10/17/09 11:22:58:363 INFO   orbited.start      Listening http@9000
> > 10/17/09 11:22:58:363 INFO   orbited.start      Listening stomp@61613
> > 10/17/09 11:22:58:372 INFO   orbited.start      switching to user
> > orbited (uid=xxx) and group adm (gid=x)
>
> > and the log files are written as user/group root.  After that I get
> > absolutely nothign in any log file.  However, when I stop orbited
> > again, warn and access suddenly fill up with entries!
>
> > It's almost as if whilst the daemon is runnign as another user the
> > logging is being suspended.  I was wondering if this may be related to
> > upstart not returning when orbited is started?
>
> I don't think it's related at all to your previous problems.
> It seems the logging facility is buffering output.
>
Ok. However, it appears to be buffered indefinitely. Log files are
*only*
written when the orbited process exits (I've waited > 24 hours to
confirm).
Any ideas why this is the case?

Best Regards,

David

Jérémy Lal

unread,
Oct 18, 2009, 9:39:38 AM10/18/09
to orbite...@googlegroups.com
>>> and the log files are written as user/group root. After that I get
>>> absolutely nothign in any log file. However, when I stop orbited
>>> again, warn and access suddenly fill up with entries!
>>
>>> It's almost as if whilst the daemon is runnign as another user the
>>> logging is being suspended. I was wondering if this may be related to
>>> upstart not returning when orbited is started?
>>
>> I don't think it's related at all to your previous problems.
>> It seems the logging facility is buffering output.
>>
> Ok. However, it appears to be buffered indefinitely. Log files are
> *only*
> written when the orbited process exits (I've waited > 24 hours to
> confirm).
> Any ideas why this is the case?

I'm not sure, but i guess it's not a matter of time,
and rather a matter of space ;)


signature.asc

davebath

unread,
Oct 18, 2009, 9:43:31 AM10/18/09
to Orbited Discussion
Haha. Very good! However, seriously disk space is fine. It feels like
it's to do with the way that orbited switches user - as soon as it
does the switch, log files are no longer written. I wonder if it's
something as simple as permissions - the log files are created before
the user switch has been performed (when user and group are specified
in orbited.cfg), and so further log entries cannot be written.
Reply all
Reply to author
Forward
0 new messages