[03:37] <twb> Is "pre-start exec" allowed (instead of "pre-start script")?
[03:38] <twb> Also: WTF just happened: stop gitit ==> stop: Method "Get" with signature "ss" on interface "org.freedesktop.DBus.Properties" doesn't exist
[03:38] <JanC> twb: yes
[03:39] <JanC> an no clue about the DBus error  ;)
[03:39] <JanC> and *
[03:39] <twb> OK, thanks
[03:39] <twb> I think it was pissed because I said "script end" instead of "end script"
[03:41] <twb> http://paste.debian.net/106276/
[03:41] <twb> Though strangely, it isn't writing anything to the logfile now I rotated it
[03:43] <JanC> hm, how does it log?
[03:43] <twb> not via syslog(3)
[03:43] <twb> I think it opens it directly
[03:45] <twb> http://paste.debian.net/106277/
[03:45] <twb> This is on lucid, btw
[03:46] <JanC> hm, and with savelog -p the permissions should be right too, I suppose
[03:47] <twb> Hmm, even if I run gitit as root, it doesn't write to that file
[03:48] <twb> Strace can see it opening the log, though
[03:48] <twb> open("/var/log/gitit.log", O_WRONLY|O_CREAT|O_NOCTTY|O_APPEND|O_NONBLOCK, 0666) = 7
[03:49] <JanC> is it supposed to write anything in absence of errors?
[03:50] <twb> Ah, I think the original 271 bytes were logs of *init*
[03:50] <twb> i.e. subsequent boots don't print anything, even for GETs
[03:57] <twb> I give up.
[03:57] <twb> BTW, do you know how to not have the extra su process hanging around?
[03:57] <twb> http://paste.debian.net/106278/
[04:19] <JanC> yes, but not sure if upstart will like that  ;)
[04:20] <twb> Tell me and I'll check
[04:20] <twb> Also re logging, it was because 'log-level: WARNING' is the default.
[04:22] <JanC> basically, su is waiting for the process it starts to end
[04:23] <twb> Why doesn't it do a forkless exec of sh -c?
[04:31] <twb> I'd use sudo instead, but I'd prefer to avoid the syslog noise from sudo
[04:46] <JanC> you can run gitit in the background
[04:47] <JanC> but upstart might not like that  ;)
[04:47] <twb> Yeah, obviously that's no good
[04:50] <JanC> I doubt the su process does any harm to your system anyway  ;)
[04:50] <twb> Sure, it's just ugly
[15:47] <anchepiece> hi all, does anyone know where the upstart/initctl status is saved? like the association between the daemon and the pid.  i have a incorrectly stopped init that is now giving the 'start/killed' with a non-existant pid
[15:47] <anchepiece> i was hoping to clear the config somewhere
[16:08] <JanC> it's "saved" in memory only
[16:15] <JanC> http://heh.fi/tmp/workaround-upstart-snafu might be useful 
[16:31] <SpamapS> anchepiece: just stop the job .. 
[16:33] <SpamapS> Oh I see.. can't kill the pid that doesn't exist. Interesting.
[16:44] <SpamapS> JanC: where did that workaround-upstart-snafu script come from btw?
[16:45] <JanC> SpamapS: ion pointed to it a couple of days ago
[16:49] <SpamapS> Seems like init would know about any pids it was tracking dying.
[16:51] <JanC_> grrr, why does my ISP insist on 36-hourly disconnects...  :-(
[16:51] <JanC_> SpamapS: ion pointed to it a couple of days ago
[16:51] <JanC_> I guess it's his script
[16:52] <JanC> maybe it was tracking the wrong pid though?
[18:29] <anchepiece> SpamapS: i cant find that script online anymore
[18:29] <anchepiece> have a copy
[18:29] <anchepiece> ?
[18:32] <JanC> anchepiece: if you mean the snafu script, it's still there?
[18:32] <anchepiece> the url is 404
[18:33] <JanC> not from here...
[18:33] <JanC> you in some place where internet is filtered?
[18:33] <anchepiece> ah its back!
[18:33] <anchepiece> thanks
[18:37] <anchepiece> well it just spawns infinit threads
[18:37] <SpamapS> JanC: my point is that even if it was tracking the wrong pid.. if the pid it is tracking dies.. it will know and respawn or not .. 
[18:37] <anchepiece> i think ill wait till a reboot and leave the renamed daemon 
[18:38] <SpamapS> anchepiece: so status foo shows a pid that doesn't exist?
[18:38] <SpamapS> anchepiece: or status foo shows infinite pids ?
[18:38] <JanC> SpamapS: it won't (always) respawn infinitely though
[18:38] <anchepiece> status foo shows a pid that doesdnt exist
[18:38] <SpamapS> JanC: right, I'm more saying that I can't see a situation where upstart shows a pid that is dead in status.
[18:39] <anchepiece> the workaround-snafu prints out an increasing number (new pids?)
[18:39] <SpamapS> seems like a bug somewhere.
[18:39] <SpamapS> that workaround-snafu may take forever on a system that uses pseudo random pids.
[18:39] <JanC> I've never seen it happen myself
[18:39] <anchepiece> the bug was my fault (putting an expect fork when there shouldnt have been, then prematurely ctrl-c killing the stop command when it stalled)
[18:40] <anchepiece> no it increments
[18:40] <JanC> SpamapS: yeah, in theory it can as well take 100 years or something  ;)
[18:41] <anchepiece> ie: start/killed, process 13790 ./workaround-upstart-snafu 13790  prints out the next pid available past 13790 like 22xxx then counts up as it creates new pids
[18:41] <SpamapS> interesting
[18:41] <anchepiece> going to leave it running just to see what happens
[18:42] <anchepiece> ok it dropped back to 1000s
[18:42] <anchepiece> now i understand how it works
[18:43] <JanC> it tries until a process with that PID exists
[18:43] <JanC> then we hope upstart gets unconfused  ;)
[18:44] <anchepiece> it did, but it respawned the old conf
[18:44] <JanC> it's normally used for a slightly different issue though
[18:44] <anchepiece> nowe stop is hung 
[18:47] <anchepiece> i think this tool will work
[18:47] <JanC> upstart needs a built-in "unbreak" command I guess  ;)
[18:47] <anchepiece> well maybe a non-ruby dependant version of the script will do
[18:47] <JanC> that should be easy enough
[18:48] <JanC> it just forks until a process has the requested PID
[18:49] <SpamapS> JanC: the issue is that upstart can only do anything if a process's parent pid is 1.. it does that by either keeping it in the foreground, or ptrace attaching.. so somewhere, it detached from the process without making sure it was dead. That seems to be the bug.
[18:50] <anchepiece> it worked -> status: Unknown job:
[18:50] <anchepiece> thanks for help
[18:51] <SpamapS> anchepiece: glad its resolved for you.. but thats pretty ugly.. forking through the whole pid namespace. :-P
[18:51] <SpamapS> err.. pid space..
[18:52] <JanC> SpamapS: that's why it's called a workaround  ;)
[18:52] <anchepiece> and now respawning on a crash is working perfectly
[18:53] <anchepiece> i vote to add that script or a bash variant to the release package 
[18:54] <JanC> fixing the bug would be better  ;)
[18:54] <anchepiece> a long-term state of stopped/killed with a pid may be a clue
[18:55] <JanC> a command to tell upstart it has to forget or force the status of 1 particular job could be useful too
[18:55] <JanC> but of course that's still a workaround
[18:56] <SpamapS> Yeah
[18:56] <SpamapS> better workaround
[18:56] <SpamapS> It actually may be this bug https://bugs.launchpad.net/upstart/+bug/539175
[18:56] <SpamapS> but.. in reverse
[18:59] <anchepiece> https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/438313    https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/504989   https://bugs.launchpad.net/upstart/+bug/406397  
[19:03] <SpamapS> anchepiece: thanks.. that does look like the problem
[19:18] <ion> The real fix is the proc connector implementation that Just Works™. Meanwhile, people just need to use ‘expect’ only when they’re 100 % sure of the forking behavior of their main process.
[19:22] <SpamapS> given the response tho
[19:22] <SpamapS> the existence of a "verify pids" workaround seems needed
[19:23] <SpamapS> also it would make sense for init to just verify that its signal was acted on by checking the entry in /proc if available
[19:24] <ion> Backups are needed for people who delete important stuff by mistake. Yes, people shouldn’t delete important stuff by mistake.
[19:25] <ion> Anyhoo, a clean patch that is not too nasty a kluge might make it into Upstart.
[19:33] <ion> …if Keybuk approves it, of course. :-)
[19:39] <Keybuk> what do I have to approve?
[19:52] <ion> People have been suggesting that Upstart check the pids it thinks it’s tracking actually exist as a workaround when people confuse Upstart with incorrect use of ‘expect’. That is, until the proc connector implementation is there, of course. I said your approval is needed for a patch if someone feels like creating one.
[20:00] <Keybuk> how would it "check" the pid?
[20:02] <ion> In any case, it would be a kluge. I didn’t really give thought to how to avoid a race condition etc.
[20:14] <Keybuk> reminds me that I must finish my new supervisor code, give that to everyone to play with
[20:19] <ion> The proc connector code?
[21:04] <yuantai> Hello! I hope I'm in the right channel. I have a question on upstart. I have a daemon to monitor the power status. It needs to intercept shutdown/reboot event, i.e. runlevel 0 and 6, and before network goes down, it needs to report to a centralized server. My question is: in upstart how to I define "before network goes down and after shutdown/reboot"?
[21:20] <yuantai> Or can someone point me to the right place/mailing list to ask the question? Thanks!
[21:24] <anchepiece> yuantai: i think if you stick around a bit someone will have a good answer for you.. 
[21:24] <anchepiece> i think yuo can throw a script into here though: /etc/network/if-down.d
[21:24] <anchepiece> /etc/network/if-down.d/upstart i mean
[21:29] <yuantai> thank you anchepiece,
[21:31] <yuantai> I'm doing it on a RHEL6 machine, it doesn't have the /etc/network/if-down.d/upstart. Is it only in Ubuntu? 
[21:33] <anchepiece> http://upstart.pastebin.com/vz8hq557
[21:33] <SpamapS> yuantai: how about start on starting rc RUNLEVEL=[016]   ?
[21:33] <anchepiece> thats the initctl emit
[21:34]  * SpamapS doesn't know if RHEL6 uses rc either :-P
[21:34] <anchepiece> that file is in marked executabe in /etc/network/if-down.d/ dir
[21:39] <yuantai> Thanks SpamapS, it seems RHEL6 also uses rc.
[21:39] <SpamapS> yuantai: note that that will make it run *before* the shutdown commences
[21:39] <SpamapS> yuantai: but, as soon as your job finishes, the rc will start and shutdown
[21:41] <yuantai> anchepiece: I'm wondering if I can use this code in my own machine? 
[21:43] <anchepiece> in a conf file add a "start on net-device-down"
[21:43] <yuantai> SpamapS: in this combined format, can I find out which runlevel the admin issued? My daemon also needs to know whether it's reboot or shutdown
[21:46] <yuantai> anchepiece: for "start on net-device-down", is it going to run when ifdown command is issued?
[21:47] <anchepiece> you need to drop that script in /etc/network/if-down.d/ ,which will emit and read in your conf
[21:47] <anchepiece> so yes
[21:47] <SpamapS> yuantai: yes $RUNLEVEL will be set to it I think
[21:47] <anchepiece> i guess that ubuntu is much more tightly integrate with upstart than fedora/redhat
[21:48] <SpamapS> anchepiece: I don't know if they have that in fedora/redhat
[21:48] <anchepiece> /etc/network/if-down.d/ ?
[21:48] <anchepiece> oh hrm
[21:48] <anchepiece> yes you're right
[21:49] <anchepiece> well, on this older fedora c7 its not there
[21:50] <anchepiece> but i see mention of it in fc13
[21:51] <anchepiece> i guess look thtough /etc/sysconfig/network-scripts
[21:52] <yuantai> thanks anchepiece, yes it's in /etc/sysconfig/network-scripts, 
[21:55] <yuantai> But is this folder the upstart scripts?
[21:56] <anchepiece> i think you'd have to add a call yourself to the /etc/sysconfig/network-scripts/ifdown script (see how OTHERSCRIPT is run, duplicate that)
[21:56] <anchepiece> sorry have to go but you are close
[21:56] <yuantai> thank you anchepiece