/srv/irclogs.ubuntu.com/2012/05/01/#upstart.txt

steffen_bhaving trouble to understand instance handling 14:16
SpamapSsteffen_b: its fairly simple if you consider that all jobs start with an instance value of ""15:28
SpamapSsteffen_b: the instance keyword just expands that a bit so that there can be multiple instances of a job if need be, by introducing variables15:29
steffen_byes - but i can stop a single instance by "stop on " condition ?15:29
SpamapSsteffen_b: all instances will stop based on the stop on, though you can use the same variables in the stop on as you do in instance15:30
SpamapSsteffen_b: so if you have 'instance $FOO' and 'stop on stopping other-job FOO=$FOO' that works 15:30
steffen_byes - guess what i tried was just bad idea 15:31
steffen_bi wanted to track 2 events and making instance for each 15:31
steffen_bif both happened (state saved in instance) 15:31
SpamapSsteffen_b: for what purpose?15:31
steffen_bi can start something else15:32
SpamapSso like 'start on started something-state EVENT=foo and started something-state EVENT=bar' ?15:32
steffen_blogically yes15:33
steffen_bexcept upstart doesnt work like that 15:33
SpamapSwell, it might, I think we're far too abstract.15:33
SpamapScan you be more concrete?15:33
steffen_bi have Xorg (job called openbox) and i have vdr (job called vdr) 15:34
steffen_beach emits an upstart event openbox-started vdr-started once really completed15:35
SpamapSyou know upstart does that for you15:35
SpamapSright?15:35
steffen_bmaybe on paper15:35
SpamapSno it does it, in code. :)15:35
steffen_bnot really believe me15:35
SpamapSSomehow we've managed to get upstart to do that to boot Ubuntu :)15:36
SpamapSnow, perhaps you're not familiar with some of the idiosyncratic ways to control the timing of that event emission15:36
steffen_ba daemon forking doesnt mean its ready to connect 15:36
SpamapS*agreed 100%*15:36
SpamapSthats why we have post-start15:36
SpamapS'started' is not emitted until post-start exits15:37
steffen_bi only know from inside the daemon, once completed15:37
steffen_bnow tell me how i get this outside15:37
steffen_band use it in post start15:37
SpamapStouch a file15:38
SpamapSwhile ! [ -f $file ] ; do ... 15:38
steffen_band loop sleep 1 ?15:38
SpamapSor open a socket15:38
SpamapSor a fifo..15:38
SpamapSlots of ways to do it15:38
steffen_bexcept the famous while ... sleep ... there is still no way15:39
SpamapSalso you can use 'expect stop'15:39
SpamapSand send yourself SIGSTOP15:39
SpamapSupstart will send you SIGCONT and the emit started15:39
steffen_bin post-start ?15:40
SpamapSno you don't need a post-start if you use expect stop15:41
SpamapSI don't know of any jobs that use that method right now btw15:42
SpamapSlooping or using a fifo in post-start is the only method I've seen really15:43
steffen_bat the moment i have start on started vdr and in the client i loop until socket is availble 15:43
steffen_bwhich is painfull since this adds up to plenty of loops waiting and still keep them sort of syncronized in different cases15:44
SpamapSis that a local socket?15:44
SpamapSbecause, if its ever intended to be over a network, you should probably just keep that strategy.. you can't coordinate events over the network ;)15:44
SpamapSat least, not w/ upstart :p15:45
steffen_blocal network, local fd, dbus ...15:45
steffen_bx15:45
steffen_bsound15:45
SpamapSsteffen_b: yeah, post-start seems like the simplest way forward, but if you want to build in upstart support, use the 'expect stop' method described in 'man 5 init15:49
steffen_bmight be worth a try - allthough we just added something to emit an event from daemon 15:52
steffen_bsounds like a way to keep it on one place 15:53
SpamapSsteffen_b: emitting an event is fine too, its actually pretty cool. :)16:01
SpamapSsteffen_b: also, I believe there is a new initiative to track exits, not just forks, so that daemons that do the right thing and keep the parent alive until the service is ready, will work fine16:02
steffen_bwell there is also some fight with emitting an event as well 16:09
steffen_bdaemon is running as user - upstart event is send from user over dbus16:09
steffen_bsince inclusion of user jobs this means you can not control system jobs from user (except you switch that off i guess)16:10
steffen_bso migrating depending jobs to be user jobs 16:11
steffen_bwhere this user jobs are jobs of a system user - doesnt really sound like something which should be handed to the user16:13
steffen_bguess a step back and think again 16:13
SpamapSsteffen_b: sounds like another reason to think about expect stop16:13
steffen_byes16:13
SpamapSsteffen_b: does your daemon keep its parent alive until it is ready?16:13
steffen_bit never forks i think 16:14
steffen_bi have no expect currently and it works :)16:14
steffen_bits tracing the right thing 16:15
steffen_bto know when its ready we using a plugin to the daemon which signals us from the first loop after initializing16:20
steffen_bso vdr and upstart dont like each other 16:21
SpamapSah ok16:21
SpamapSI do kind of wish we could have something like 'expect socket /var/run/foo.sock'16:21
steffen_bthe systemd kind of handling it 16:22
steffen_byes16:22
steffen_bnoch socket activation but buffering 16:22
steffen_bnoch -> not16:23
steffen_bthat would simply the thing i try by 50%16:23
SpamapSI don't like socket activatino16:24
SpamapSit simplifies the thinking, but not necessarily the implementation16:24
steffen_bthere are few things which are cool in theory - but in reality you need to workaround more things than you like16:26
steffen_bexpect /dev/foo16:27
steffen_bexpect tcp://localhost:3789016:27
steffen_bexpect /tmp/foo 16:27
steffen_bwould for sure make things simpler16:27
steffen_bif that expect is state-like 16:28
SpamapSit doesn't need to be state based16:29
SpamapSjust treat the appearance of a file/socket/etc. as an event16:30
SpamapSand then we can use a job to track its state16:30
steffen_bstates are more natural16:34
SpamapSare they?16:36
steffen_b100%16:36
SpamapSAlso, upstart *is* state based16:37
JanCstates & events need each other, so one isn't natural without the other16:37
SpamapSyou can track states w/ jobs16:38
steffen_bbut you need inictl status <jobname> | grep -q "^jobname.*running" 16:38
steffen_bin an upstart job 16:39
steffen_bwhere are the states at this point ?16:39
steffen_banyway  - this is not  blaming or being negative - just sharing thougts hope you dont get it wrong :)16:45
SpamapSsteffen_b: that *is* the state :)16:45
steffen_b:D16:46
SpamapSif you look on a recent ubuntu system, you'll see the workaround for not having them built in.. /etc/init/wait-for-state.conf16:46
SpamapSstart wait-for-state WAITER=me WAIT_FOR=somejob16:46
SpamapSthat lets you use jobs like condition variables basically16:46
steffen_bwasn't that the workaround for "starting ... or starting ..." second one did not wait anymore ?16:47
steffen_buntil job is started16:48
SpamapSyeah, well, thats basically the same problem16:50
JanCmaybe what we really need is an init daemon that can be configured with low-level state/event instructions, and then write compilers that turn all sort of job/unit/initscripts/... in config for it  ;)16:54
=== SpamapS_ is now known as SpamapS
=== bradleyayers_ is now known as bradleyayers
=== alienth_ is now known as alienth

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!