[09:38] spamaps: ive been trying out all the options, expect fork, expect daemon, expect stop... even tried no expect [09:39] glenn___: you need to know how many times the app forks initially before it is ready to start its real work (in other words its initialisation phase). [09:41] jodh: i tried the count on fork/clones... it is about 22 [09:41] but the strace is showing clones, not forks [09:42] glenn___: the maximum any process needs to fork is twice before it is fully initialized. [09:42] jodh: so the guys cant code at puppetlabs? :) [09:42] glenn___: any further forks are for setting up "helpers". You don't care about those though - you need the pid of the master parent process before it does its fork bomb. [09:43] jodh: the master process is about 22 pids later [09:43] glenn___: it can't be. [09:43] ill show you [09:46] root@puppetclient:/etc/init# start puppet [09:46] puppet start/running, process 1142 [09:46] root@puppetclient:/etc/init# ps auxf |grep puppet [09:46] root 1167 0.0 0.0 9744 876 pts/0 S+ 10:46 0:00 \_ grep --color=auto puppet [09:46] root 1163 7.0 3.9 122540 40488 ? Ssl 10:46 0:00 /usr/bin/ruby1.8 /usr/bin/puppet agent [09:46] root@puppetclient:/etc/init# [09:47] i can use the init script to shut it down, not with upstart [09:48] init script is using the pid file [09:49] root@puppetclient:/etc/init# grep clone /tmp/strace.log | wc -l [09:49] 24 [09:50] 1217 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f6ee51809f0) = 1218 [09:51] etc etc [09:51] 1217 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f6ee51809f0) = 1238 [09:51] it behave the same for version 0.25 2.6 and 2.7 [09:52] the expect options go to a max of 2, i think with daemon [09:53] so either upstart isnt the right tool, their daemon is weird, or i just dont get it [09:53] ive been trying for at least an hour :) [09:59] fyi, the daemon is just a ruby script, starting puppet from ruby [10:00] i suppose thats causing the problem [10:08] glenn___: as stated, there is no reason to fork more than twice (that's why upstart only tracks up to 2 forks). I think you should talk to the puppet guys to understand what is going on there. For now, you might need to consider using start-stop-daemon with upstart: http://upstart.ubuntu.com/cookbook/#alternative-method [10:10] jodh: i think i picked the wrong software to test upstart :) [10:11] glenn___: this isn't a problem with upstart - it's either ruby and/or puppet. [10:11] jodh: hence my point :) i picked the wrong software <- puppet [10:14] glenn___: are you using "respawn" by any chance? [10:15] jodh: if i use any expect it all start will hang [10:15] s/it/at [10:15] glenn___: but are you using "respawn"? [10:15] jodh: nope [10:16] that started the process several times [10:16] :) [10:16] jodh: sorry i misread i thought u said expect instead of respawn [10:17] glenn___: ok. please keep us posted on this as we need to understand exactly what is going on here. [10:17] jodh: im trying to get it to work with start-stop-daemon first, then ill try the puppetlabs guys [10:19] which doesnt work at all :( [10:19] exec start-stop-daemon --start --exec /usr/bin/puppet agent [10:23] i did a reboot though, now its starting [10:23] still the same issue though, seems to make no difference [10:25] glenn___: what problem? why are you rebooting? I'd get puppet working with start-stop-daemon on the command-line first, then put that into an upstart .conf file. [10:25] jodh: it is working on the commandline [10:25] jodh: i tried start puppet, it hangs, i reboot, i start it again and it works [10:26] jodh: i tried several reboots :) the upstart wass messed up [10:26] sometimes it even keeps track of the pid while that id is not even there anymore [10:27] glenn___: that's telling you your .conf file is incorrect - upstart just does what you tell it to :) [10:27] there is just a few lines [10:27] to be exact 4 [10:28] description "puppet client" [10:28] start on filesystem or runlevel [2345] [10:28] stop on runlevel [!2345] [10:28] exec start-stop-daemon --start --exec /usr/bin/puppet agent [10:31] also when i try stop, it says unknown instance, which would mean the job is not running, while it is... [10:31] need more spresso [10:32] glenn___: your 'start on' is incorrect - that will try to start *two* instances of the job (which will fail). [10:32] glenn___: make it 'start on runlevel [2345]' [10:35] same behaviour [10:37] i dont think this will work with upstart :( [10:37] for now [10:43] i have an idea perhaps it will help === glenn___ is now known as glenn [11:05] glenn___: glenn: 'exec start-stop-daemon --start --exec /usr/bin/ruby /tmp/fork.rb' works as expected for me. [11:07] jodh: thanks for checking [11:07] jodh: it just does 1 fork i suppose? [11:19] jodh: could show me the contents of that ruby file [11:20] glenn: http://paste.ubuntu.com/816328/ [11:23] jodh: yup seems to work correct [11:50] jodh: when i include their code in the fork.rb script it forks 21 times [11:51] glenn: maybe you should raise a bug on that - sounds broken. [12:17] this is kind of nice [12:18] there is a flag called --no-daemonize, with that it works as expected [12:20] glenn: great. please raise the issue with the puppet folk though as it sounds like there is a bug in there. [12:20] im staring at their ruby code for half an hour now :) maybe ur right [12:27] interesting material though [12:28] they are using Process.detach [12:30] lol :) [13:20] jodh: jodh: im pretty sure its something weird in their code [13:22] http://paste.ubuntu.com/816410/ http://paste.ubuntu.com/816411/ [13:23] 'music [13:23] oops :) [13:23] music? :) [13:23] jodh: i appreciate ur help btw [13:23] ignore - tmux window searching :) [13:23] learning a lot regarding upstart [13:23] should just use spottify :) [13:24] glenn: glad your'e making progress. afk for a while ... [15:03] jodh: im filing a bug at puppetlabs right now after discussing it with someone in their irc-channel [15:09] glenn: great news! [15:10] jodh: Yup :) [15:10] jodh: im not exactly sure what to file but hey :P [15:10] its something with redmine facter within puppet [15:10] its doing system calls to which, ifconfig, hostname things like that [15:11] that seems to spawn the forks [15:11] which seems correct because in the strace there is exec's to that [15:12] jodh: and i probably have a workaround for now to upstart [15:14] woot :) [15:14] root@puppetclient:~# start puppet [15:14] puppet start/running, process 1806 [15:14] root@puppetclient:~# stop puppet [15:14] puppet stop/waiting [15:14] nice [15:14] :)_ [15:47] jodh: for my understanding, if software is daemonized, this should take no more then 2 forks? [15:47] glenn: there is no additional benefit to forking more than twice. [15:47] jodh: could you explain that a bit more [15:48] glenn: not right now (in a meeting). it's standard unix/linux semantics though. [16:35] glenn: I'm curious what your workaround was [16:36] spamaps: ah :) ill paste my script [16:36] spamaps: im kind of confused still, regarding the max of 2 forks in upstart === SpamapS_ is now known as SpamapS [16:36] spamaps: im using the --no-daemonize function for puppet [16:37] glenn: puppet may be an example of something that reasonably *does* fork twice before daemonization for legitimate reasons.. I think this may be worth a bug report in upstart [16:37] Why shouldn't a program be able to exec stuff before it daemonizes itself? [16:37] spamaps; thats the same disucssion i had with our developers [16:38] jodh: ^^ Perhaps 'expect exit' will fix this? [16:38] spamaps: maybe it should track only forks of itself, instead of all other calls [16:38] spamaps: upstart seems to track all pid's instead of just the forking of the daemon itself [16:39] glenn: well its trying to figure out what the "main" pid is [16:39] spamaps: i understand [16:39] The method it uses works for most regular daemons. [16:40] spamaps: but in the puppet case, it does about 20 system calls, and then it has all the information for starting the daemon (dont ask me why) [16:40] glenn: I think I understand why.. and this is an example of where expect fork is just incapable of doing it right [16:41] So --no-daemonize is the only other option.. though then you have the trouble of needing to write a post-start which determines when the daemon is actually ready [16:42] its working properly already [16:42] when puppet is not daemonized it will run in the foreground, and thus not doing forks to system calls [16:42] or however i should pronounche this :) [16:42] glenn: perhaps puppet should add a --upstart mode where it sends itself SIGSTOP when it is ready (upstart will SIGCONT it) [16:42] glenn: then you could use 'expect stop' [16:42] spamaps: yeah that would be a solution [16:43] glenn: you're saying system calls, but what you mean is it is forking and execing system programs, I assume [16:43] spamaps: i think so yes :) [16:43] spamaps: correct me if im wrong, this is kind of new genre too me [16:43] the paste right [16:44] glenn: that should be valid and expected behavior for lots of daemons, not just puppet. [16:45] spamaps: but its not really nice of upstart to say: build in an upstart function :) [16:45] else we dont support you [16:46] the problem exists because upstart wants to track the pid itself [16:46] my mind is boggling [16:50] http://paste.ubuntu.com/816657/ [16:50] there this is one works [16:50] glenn: well its more of upstart saying "help us determine your pid" [16:50] spamaps: puppet creates a pid file already [16:50] spamaps: why would upstart need to find it again? :) [16:50] glenn: IMO, upstart should have the ability to use pidfiles, but Keybuk is (was?) convinced that pidfiles are too unreliable. [16:51] spamaps: upstart is more unreliable [16:51] :) [16:51] Not sure I agree with that [16:51] spamaps: concerning starting software [16:51] but I can see how it might feel that way given the difficulty in writing jobs [16:51] i was reading the cookbook [16:51] it seems really awesome [16:51] a new init [16:51] glenn: upstart is actually quite reliable.. its just that it reliably does weird things. :) [16:51] its fast, parallel et [16:52] but the pid tracking, is really weird [16:52] i did some reboots, and even 2 reinstalls (through auto deployment) [16:52] it was tracking pid's that didnt exist [16:52] using ptrace the way it does is the only thing I don't like [16:52] even restarting upstart didnt help [16:52] glenn: the tracking pids that don't exist thing is a known bug [16:53] glenn: happens whenever you use expect fork on something that doesn't fork [16:53] glenn: or.. something like that, I forget. Anyway, there's a workaround that doesn't require a reboot.. but it does require you to exhaust pid space and roll-over [16:54] glenn: anyway, the --no-daemonize option is still the simplest. But again, if you have other things that might depend on it running.. you need to have a post-start that verifies it is ready to serve their requests. [16:54] also the --no-daemonize thing fails on programs that fork/exec/exit on SIGHUP .. which I just figured out python-paste does. [16:56] spamaps: ah ok, i tried the expect option, that probably created the issue [17:01] spamaps: spamaps: --no-daemonize is a flag specific for puppet [17:03] glenn: right, its pretty common for daemons to have a "stay in the foreground" flag tho [17:10] spamaps: still, the pid tracking seems a bit strange [17:11] spamaps: i can imagine a lot of software does exec system programs before it starts [17:11] + as daemon [17:11] glenn: when daemons behave the way upstart expects them to, its quite nice. But I estimate thats only about 50% of daemons that I've tried to write jobs for [17:12] spamaps: well if upstart wants to be ground breaking, either a pid file support should be available, or software developers need to code in sigstop [17:12] spamaps: i dont think there is a common practice for this when developing software [17:13] spamaps: the only thing i could think of is that there should be a pid file [17:13] spamaps: which there is, but upstart wont support it [17:14] spamaps: also, software like puppet is supported on redhat and not on ubuntu [17:14] glenn: thats just crazy talk. puppet is very well supported on Ubuntu [17:14] glenn: upstart's pid tracking is not necessary to use services. [17:15] glenn: you can have an upstart job with no pid, that just tracks whether or not the boot/shutdown thinks it should be started/stopped [17:15] spamaps: the enterprise version is indeed supporting ubuntu now, sorry for that [17:16] and puppet is in main [17:16] so it is supported by Canonical [17:16] spamaps: i had the newer puppet backported to lucid [17:16] from onerice [17:16] -e [17:16] I think we (Ubuntu) should backport more stuff to LTS's [17:17] spamaps: i had some great help from people at ubuntu getting this to work [17:17] took about 1 month i guess [17:17] now 2.7.1 is in lucid backports [17:17] glenn: thank you for working on backports then!! [17:17] lol np [17:17] I hope to have some official Canonical resources working on backports going forward [17:17] at least, for server [17:19] that would be nice [17:19] i did some cool stuff to debian preseed too :) [17:19] but that was just on my side, not on the preseed package [17:39] can an upstart job tell the difference between a restart and stop? i.e. can I make my job do something else than a simple stop/start during a restart? [17:41] trondm: no [17:42] trondm: restart simply changes the goal to stop, then back to start [17:42] trondm: its a dangerously misunderstood command.. it does not re-load the upstart job. [17:42] Ah. Too bad. [17:43] In my case, I have a parent job than spawns several instances. I'd like each instance to be restarted separately when the parent is restarted, instead of having them all be stopped, then started [17:44] trondm: it sounds the same, restart them all, or stop them all and start them all [17:45] It's not a huge problem, though (and this is the way it worked before I started using upstart) [17:47] (I was just hoping it would be possible to improve on the current state) [17:48] trondm: is there is difference when you restart your instance or stop/start your instance? [17:49] glenn: there's a difference between stop/start 0; stop/start 1; stop/start 2; and stop 0 1 2; start 0 1 2. Basically I'm offline for a shorter period if everything stops, then starts. [17:49] as far as i knew restart == stop -> start [17:49] oh ic [17:49] maybe you can create several jobs? [17:50] or would that do the same [17:54] I think that would do the same. Part of the problem is that the parent is an instance itself, and it's not possible to use variables in the "stop on" stanza. So I have a "post-stop" script in the parent that stops all child-instances [17:58] hey spamaps you know what would be nice [17:59] the documentation regarding expect doesnt mention what to do if there is more then 2 pid forks [18:01] i.e. you should change the software, or use sigstop [18:09] jodh: spamaps: http://projects.puppetlabs.com/issues/12146 [18:09] i just made this issue [18:09] hopefully it makes sense [18:20] thanks a bunch again for your support/help really appreciate it [18:20] im off, gonna play starcraft 2 [18:20] yo