=== robbiew is now known as robbiew_ [12:05] can anyone tell me what happens when you do stop jobname ? ie what events are sent [12:06] current my job starts but does not stop so guessing it need to handle specific events [13:11] is there a way to debug upstart scripts i am running stop scriptname and its locking the terminal [13:12] i can press ctrl + c to cancel but how can i find why it never stops its probably my program but i want to modify it to work correctly ? [14:18] oly: locking the terminal is rare. Are none of the other vts working? [14:21] sorry vts ? i am new to upstart [14:21] oly: other virtual terminals [14:22] oly: ctrl+alt+f(2-6) [14:22] yeah its not locking like that it just does not return to the prompt [14:22] oly: ok, open another terminal [14:22] yep [14:23] oly: initctl list should give you something to go on [14:23] oly: hopefully you'll get a pid from there. Then you can attach gdb to it and go nuts [14:24] usm start/killed, process 22445 thats what it says [14:24] and its still sat at the prompt in the other terminal trying to start [14:25] there any examples around for a python daemon script [14:26] as my program is a python web server basically [14:30] oly: start/killed means it was planning on coming back up... [14:30] oly: try kill -9 22445 [14:31] says theres no such process [14:32] which i have just confirmed with ps -A | grep 22445 [14:34] oly: ok, that's a problem... [14:34] Keybuk: any ideas? ^^ [14:35] i guess its something i have done i have been trying things with the scripts to get it working [14:35] oly: does your job have pre-stop/post-stop scripts? [14:36] nope at least not now [14:36] oly: http://www.python.org/dev/peps/pep-3143/ might be the best place for info about writing a unix daemon in python [14:37] okay i have a lot of that code, is there anything on the upstart side for a program like that ? [14:37] or can some one recommend me a good exmple that should work with that sort of program [14:38] once i know the upstart script is correct i can start checking my code [14:38] at the moment prestart echo does not even print [14:38] guessing thats to do with the usm start/killed message [14:38] is there any way to clear that ? [14:39] http://pypi.python.org/pypi/python-daemon/ --> a library implementing correct daemon behaviour [14:41] oly: if the task is dead and gone then upstart should be moving along [14:43] those links are great think i used them to write it originally [14:43] can i reset upstart so it rechecks some how ? [14:43] oly: try doing stop usm again [14:44] ugh. I need to get the code in front of me... [14:44] usm stop/killed, process 22445 [14:44] now says already stopped [14:45] perhaps it just takes a very long time to stop [14:48] oly: it should be stop/waiting [14:48] the process is gone, but the state machine isn't progressing === robbiew_ is now known as robbiew [14:48] and I forget what's supposed to happen in the Killed state so I don't know what to look for [14:49] oly: check ps for entries [14:49] none related only ones are for chromium [14:50] usually means that upstart has the wrong pid for the process [14:50] ie. expect fork when you meant expect daemon [14:50] Keybuk: but it got to the running state. It didn't hang until he stopped it [14:51] was the pid right when it was in the running state? [14:53] unknown and cant restart now [14:53] actually will just check that [14:54] yeah because its not cleared from upstart it never starts now [14:54] upstart should really deal with these kinds of crap situations better, though I think proc connector will make most of that irrelevant [14:57] thanks for the help, useful info anyway [14:58] also check that the ppid of your daemon is actually 1 [14:58] sometimes you end up watching a pid that has a different parent [14:58] if ppid != 1, then upstart will never know it died [14:58] sometimes Upstart follows the wrong fork, for example: [14:58] expect fork [14:58] script [14:58] OPTS=$(cat /etc/default/options) [14:58] exec my-daemon $OPTS [14:58] end script [14:59] in that case, upstart ends up with the PID of "cat" [14:59] and since cat is a child of the shell, the shell gets the SIGCHLD not upstart [14:59] so it fails [15:00] its kind of astonishing how many ways this thing can break [15:00] yeah well i guess i should have used ecpect daemon instead of fork from a comment further up [15:01] currently my daemon is not running and nothing with the pid upstart has is running [15:02] daemon means "forks twice" [15:02] not once [15:03] unfortunately posix doesn't seem to offer a version of kill that lets you load the arguments, so you can't send a manual CLD and get it going again [15:03] hum could this be an issue my program has child daemons which are still running [15:04] oly: no, upstart likely lost those [15:04] i did not think upstart would care about those [15:05] it won't [15:05] killed them anyway [15:06] also can upstart handle my app if i dont start it as a daemon ie so that it would lock the terminal [15:07] as i can do this as a test by passing a prameter to the program [15:07] oly: it could work [15:08] oly: actually no, upstart would grab the initial process and fall over immediately [15:08] okay [15:11] well thanks for the help will try again a bit later i think [15:29] if anyone happens to think of a way to clear upstarts current list other than rebooting let me know :) [15:30] oly: kill -HUP 1, but that will make it forget /everything/ its managing [15:31] okay that will do for now [15:31] at least while testing [15:31] reboot each time would be more of a problem [15:31] exploiting bugs against bugs. isn't life grand? [15:31] lol, thats a bug is it :p [15:32] think upstart needs a new option to force remove a process from its list by id [15:32] oly: kill -HUP re-executes init. Technically this should have no noticeable effect. [15:32] oly: maybe. It'd be better if it just managed services better (and it will.) [15:36] yeah that would be better, but some times it nice to have a fall back option in place [16:30] oly: Upstart should never lose the process [16:30] I'd rather spend time fixing those bugs [16:30] otherwise some idiot will come up with something that deliberately tells upstart to lose pids because of some other problem, etc. [16:31] fair enough [16:32] but it seems if i for example writes bad code i coudl always break it even if its not intentional [16:32] unless it keeps following the path of my programs forking [16:33] right, that's the correct fix ;) [16:33] ah okay :p [16:33] oly: eventually upstart will track everything your program forks off until one of them calls setsid. [16:33] oly: this has just taken some kernel infrastructure (now in place). [16:33] aha that would be good [16:34] what would happen if you branched of seperate programs from it ? [16:34] oly: they would call setsid() [16:34] oly: that's just good unix practice [16:34] my program launches itself then two sub process as different userts which it communicates with using ipc [16:34] aha fair enough [16:42] oly: ah [16:43] but in that case, you want upstart to know about all three pids [16:43] you might even want it to, if one of the pids dies, to deliberately send SIGTERM to the other two so that the process can be respawned [16:46] maybe, although the main program currently manages the other processes so thats not really important [16:46] ah, but if it segfaults ... [16:47] i guess, but for now i would just be happy to stop and start the main program with upstart :) [16:48] Keybuk: to an extent thats useful. In reality to do that right the daemon would have to tell upstart which pids are what and what they mean. If an apache worker dies we ignore it. If the apache master dies we need to kill the workers. [16:48] might as well create it for modern linux system as it requires a lot of modern software to function :p [16:48] sadmac: sure [16:49] Keybuk: I'm guessing libupstart will return for some of this. A lot of apps will want to give little hints to upstart and won't want to deal with the whole apparatus of their native dbus API to do it. [16:50] Keybuk: (naturally libupstart would be a wrapper around a few nih_dbus calls, not the old protocl) [16:51] that kind of thing, yes [16:52] I don't know the exact way apache works, but if apache master dies, won't you want the workers to finish the current request first (or does it need the master for that)? [16:52] JanC: that's more like ssh ;) [16:53] better question, would you want to restart the master while the workers are still there? [16:53] i know i would certainly want my child processes to finsh [16:53] as they have a queue of commands to pass through [16:54] there are enough interesting scenarios here that knowing about "workers" is a good idea [16:55] my program is not that intrested in the child processes as long as they are running, because it just writes commands to a text file and the children act on them [16:55] so they can carry on running after the parent has finished in fact if they did not the system would probably be a lot more unpredictable [16:56] if any of this info is of any use :) [16:56] oly: you're using a text file as a command spool? [16:56] yeah basically [16:57] oly: ...upstart aside you may want to re-examine your programming techniques [16:57] it queue up the commands because some can take a lot of time so they must not block the original program [16:57] why is there a better way than ipc type method [16:58] this was the only way i could find as all 3 program run as different users so communication between them was a pain [16:58] nothing wrong with that style [16:58] it's just using the filesystem as shared memory [16:58] tried, tested and true UNIX way of doing things, that [16:58] Keybuk: when we have...shared memory [16:58] sadmac: which is, in Linux, implemented as a filesystem [16:59] in which you create files [16:59] that you use as spools [16:59] or for that matter, pipes and unshared memory to spool from [16:59] pipes are two-way only [16:59] oly said he has two workers and a master [16:59] so fifos don't work [17:00] the master works as root which breaks of a web server into a restricted use account, and send info back to the program in the root account [17:00] thats the type of thing i needed [17:00] Keybuk: there is a way. It involves some descriptor passing (easier to do with threads but very possible with processes). [17:00] sure [17:00] I was starting to write a web server that did this. [17:00] but why not just use a file? :p [17:01] oly: are you using mmap? [17:02] nope not come across mmap [17:02] oly: ok you should at least be mmaping the file. [17:03] okay whats that do then in quick terms :p [17:03] i will research at some point [17:05] oly: It lets you access the file as though it were ram [17:05] sounds intresting [17:06] probably would have saved me a load of work writting a parse by sounds of it :p [17:06] oly: http://docs.python.org/library/mmap.html [17:06] ;) [17:08] hum, i can think of other uses for that in my program as well [17:08] :) [17:08] thanks for that [17:12] ugh [17:12] mmap is going to hurt them [17:13] my hobby: finding programs that "cleverly" mmap() files into memory, and truncating the files under them :p === robbiew is now known as robbiew_ === robbiew_ is now known as robbiew === robbiew is now known as robbiew_ === sadmac__ is now known as sadmac_home