rsyslog script
James Hunt
james.hunt at canonical.com
Thu Mar 24 16:26:29 UTC 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 24/03/11 00:43, Grail Dane wrote:
> Hi James
>
> Thanks very much for the reply :)
>
> I had added the full path to exec as well but had not updated that when
> posting (oops)
>
> Your solution to remove the variable and use the substitution has worked
> but looks untidy in comparison.
A simple solution to this *should* be to change your exec stanza to a
script section:
script
COMPAT=$(/sbin/rsyslogd -v | awk 'NR == 1{print substr($2, 1, 1)}')
exec rsyslogd -c$COMPAT
end script
However, you then run into that bug I mentioned regarding script
sections and respawn... :(
> Is there no real way to pass variables to other parts of the script?
>
> I assume, based on script now working, that the script / end script
> stanzas treat all variables as local hence not available
> outside. Is there an option to maybe have a global variable for a
> particular script that could be set inside one stanza and used
> either in another or the exec line as in my example?
This is just standard Unix semantics. See the very draft:
http://people.canonical.com/~jhunt/upstart/cookbook/#environment-variables
>
> Thanks again for the assist
>
> cheers
> grail
>
>> Date: Wed, 23 Mar 2011 09:12:10 +0000
>> From: james.hunt at canonical.com
>> To: upstart-devel at lists.ubuntu.com
>> Subject: Re: rsyslog script
>>
> On 23/03/11 01:20, Grail Dane wrote:
>> In case anyone can see room to point me in the right direction here, I
>> have recorded my latest bootup
>> messages and the one for my rsyslog looks like:
>
>> init: rsyslog main process (860) terminated with status 1
>> init: rsyslog main process ended, respawning
>
>> As you can see it seems to respawn but without an associated PID yet
>> running initctl list the corresponding entry is:
>
>> rsyslog start/running
>
>> Whereas all others with a PID also have - , process PID
>> And even though it says running, a ps yields nothing and no logs are
>> getting updated.
>
>> Any thoughts or help would be appreciated :)
>> grail
>
>> ------------------------------------------------------------------------
>> From: grail69 at hotmail.com
>> To: upstart-devel at lists.ubuntu.com
>> Subject: rsyslog script
>> Date: Tue, 1 Mar 2011 03:23:15 +0000
>
>> I seem to be stuck with this one and not sure if possible to do what I
>> am trying?
>
>> I copied the rsyslog.conf from my Ubuntu machine and changed it to the
>> below:
>
>> < ---------- start ----------------->
>> # rsyslog - system logging daemon
>> #
>> # rsyslog is an enhanced multi-threaded replacement for the traditional
>> # syslog daemon, logging messages from applications
>
>> description"system logging daemon"
>
>> start on filesystem
>> stop on runlevel [06]
>
>> expect fork
>> respawn
>
>> pre-start script
>> COMPAT=$(/sbin/rsyslogd -v | awk 'NR == 1{print substr($2, 1, 1)}')
>> end script
>
>> exec rsyslogd -c$COMPAT
>> < ---------- end ----------------->
>
>> This seems to start and assign a PID, it then terminates and respawns
>> but without a PID and consequently is not really running.
>
>> So i guess my question is: Am I not able to use variables in this way or
>> have I done it the wrong way?
>> If yes to the wrong way, would someone please educate me?
>
>> Also I am guessing this is not really a devel question ... is there a
>> support list?
>
>> Cheers
>> grail
>
>> -- upstart-devel mailing list upstart-devel at lists.ubuntu.com Modify
>> settings or unsubscribe at:
>> https://lists.ubuntu.com/mailman/listinfo/upstart-devel
>
> Hi Grail,
>
> The problem with your script is that the "COMPAT" variable is not
> "visible" to the exec stanza: Upstart runs each script section in a
> separate process. Therefore I think that your exec is actually running
> "rsyslogd -c" (which is invalid).
>
> As to a solution: you don't actually need that pre-start. You could just
> do this:
>
> exec rsyslogd -c$(/sbin/rsyslogd -v | awk 'NR == 1{print substr($2, 1,
>> 1)}')
>
> One other comment: you have specified the path to rsyslogd in your
> pre-start, but not in your exec stanza. I appreciate that the original
> .conf file has the same problem, but it is always best to specify the
> path to avoid surprises :)
>
> Finally, be careful with respawn and script sections (see
> https://bugs.launchpad.net/upstart/+bug/406397).
>
> Regards,
>
> James.
>>
- --
upstart-devel mailing list
upstart-devel at lists.ubuntu.com
Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/upstart-devel
- --
Cheers,
James.
- --
James Hunt
____________________________________
Ubuntu Foundations Team, Canonical.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk2LcLQACgkQYBWEaHcQG9f++wCcDCLrzVkzd63Rg0xCu5jN9Q98
9o8An2TxU/xBDVkrclD7u+kdAKiLcpz3
=jfNr
-----END PGP SIGNATURE-----
More information about the upstart-devel
mailing list