/srv/irclogs.ubuntu.com/2008/03/02/#upstart.txt

ion_Alright00:04
Keybukwhich seems reasonable00:07
sadmacKeybuk: still looking for a new name for the "on" stanza?01:24
Keybuksadmac: potentially01:30
sadmacKeybuk: I was thinking "when"01:31
Keybukand what would be the opposite?01:31
sadmacKeybuk: when not?01:31
Keybukthat's a bit ... odd :)01:32
Keybukespecially since the following bits would be true :P01:32
Keybuk  when started gdm01:32
Keybuk  when not stopping gdm01:32
Keybuk(except it's stopped *when* stopping gdm)01:32
sadmacOh, I thought on syntax did that all in one stanza01:32
sadmacwhen started gdm until stopping gdm01:32
sadmacbut on that note, unti'01:33
sadmacs/unti'/until/01:33
Keybukthat syntax got dropped a while back01:33
Keybukthe "until" operator's semantics got crazy01:33
sadmacah01:33
Keybukcurrent front-runner is three stanzas01:35
Keybuk"from" (morally equivalent to "start on")01:35
Keybuk"until" (morally equivalent to "stop on")01:35
Keybuk"when" (state matching)01:36
Keybukso, something like01:36
Keybuk  from tty-added01:36
Keybuk  until tty-removed $TTY01:36
Keybuk  while multiuser01:36
Keybuk(err, s/"when"/"while"/ :p)01:36
sadmacso can you pair them explicitly?01:37
KeybukI think so01:37
sadmacfrom a \n until b \n from c \n until d   Where if it starts on a it won't stop on d01:38
Keybukno01:38
Keybukyou can't do that01:38
sadmachmm01:38
sadmachow do the multi-instance jobs work then?01:38
sadmacI guess that's more environment though01:39
Keybukexample?01:39
sadmacfrom some_tty starts01:39
sadmacuntil that_specific_tty_that_started_me_stops01:39
Keybukright01:40
Keybukso you'd match that using environment01:40
Keybukfrom tty-up01:40
Keybukuntil tty-down $TTY01:40
Keybukthe tty-up event carries TTY=tty1 as an environment payload01:40
Keybukthat gets added to the jobs own environment while it's running01:40
Keybuk(in fact, for getty, that would probably be the way unique instances are determined)01:41
Keybukbecause it will be in the environment of the job, the job can match against it in its own definitions01:41
Keybukso thus:01:41
Keybuk  until tty-down $TTY01:41
sadmacI also wanted to know how you have jobs become able to be started on events without starting them01:41
sadmacI.e. `start job_x` fails01:41
sadmacI plug in a smart card, nothing results directly from this01:42
sadmacbut while the smart card is in, `start job_x` succeeds01:42
sadmacso basically "this job can only be run while in state X, but it doesn't have to be running in said state"01:43
Keybukmeans match the TTY variable from the tty-down event to the $TTY variable in the job01:44
Keybukyou'd use states for that, maybe01:45
KeybukI'm not sure how much preventing the sysadmin from doing stuff we want to do01:46
KeybukI think I'm generally inclined to think if a sysadmin tries to start job_x, even while there's no smart card in, it should let them01:46
Keybukand obviously job_x will fail and give them meaningful error messages01:46
Keybuk(ie. the daemon started will fail)01:47
sadmactrue01:47
Keybukobviously Upstart should never attempt to start it automatically01:48
sadmaccool01:49
Keybuka more interesting question is if you start a job manually, should Upstart ever stop it automatically? :)01:49
sadmacThis does bring up a point about the flags/profiles things. Usually we want to prevent a service from coming up automatically, but if after loading the profile the admin decides to start one manually himself, we should let him01:50
Keybukright01:51
sadmacOk, might be more of a unix API question, unless nih has something I don't know about, but how would I change upstart init's tty from within the source code?01:53
Keybukhow do you mean?01:53
sadmacLike make nih_info/error/whatever and the stdout of 'console output' services route to /dev/some/specific/tty01:54
Keybukeasiest way would be just to change upstart's own console01:55
Keybukie in init/main.c01:55
sadmacyeah, having trouble getting unix to do that for me.01:56
Keybukdon't you just change it? :p01:56
sadmacRight now I'm sending TIOCNOTTY to /dev/tty, and then open()ing the new tty, which should do it.01:56
Keybukdo you even *have* /dev/tty at that point? :)01:56
Keybukon a udev-based system, you only generally have /dev/console and maybe /dev/null when init starts01:56
sadmachmm.01:57
sadmacI should add that I want this to happen dynamically, and to revert the change later (I've got the revert thing figured out, if I can just change it in the first place)01:57
Keybukwithout knowing much more about Fedora, I'm not sure I can help :-/01:57
Keybukcertainly on Ubuntu, nothing other than /dev/console exists when init starts01:58
sadmacwell my current technique isn't working even when I'm testing it (well after udev starts)01:59
Keybukwhat's taht?01:59
sadmacafter the TIOCNOTTY and the change, its still logging to the same place01:59
Keybukthat could be syslog() doing that02:00
sadmacbasically I have an initctl push_tty /dev/something and an initctl pop_tty command. They appear to work, but logging behavior doesn't actually change.02:00
Keybukupstart's own log output?02:01
Keybukor the output of jobs?02:01
sadmacupstart's own02:01
Keybukthat's probably syslog doing that then02:01
sadmacahh, so nih_info outputs to syslog?02:02
Keybukdoes commenting out the openlog() and nih_log_set_logger() calls help?02:02
Keybuk(then it'll just use printf)02:02
sadmacI'll try that02:03
sadmacIn fact I should set up a test job to do things with actual job output02:03
* Keybuk yawns10:36
Keybuktoo damned windy again today10:37
=== Keybuk changed the topic of #upstart to: Upstart 0.3.9 | http://upstart.ubuntu.com/ | http://irclogs.ubuntu.com/ | https://lists.ubuntu.com/archives/upstart-devel/2007-October/000468.html | http://upstart.ubuntu.com/wiki/OutstandingIssues
=== Keybuk changed the topic of #upstart to: Upstart 0.3.9 | http://upstart.ubuntu.com/ | http://irclogs.ubuntu.com/ | https://lists.ubuntu.com/archives/upstart-devel/2007-October/000468.html https://lists.ubuntu.com/archives/upstart-devel/2008-January/000573.html | http://upstart.ubuntu.com/wiki/OutstandingIssues
Keybukdear valgrind, please exit 1 if you find an error, kthxbye20:37
ion_Heh20:37
Keybukhurrah20:45
Keybukjob->start_on is no more20:45
Keybukstart and the resulting environment are now atomic20:46
Keybukso if you "start getty TTY=1"20:47
Keybukand then do "stop --id 123; start --id 123 TTY=2"20:47
Keybukthe stop scripts will still have $TTY=120:47
Keybukand won't get $TTY=2 until it restarts20:47
ion_Neat.20:50
Keybukdo you think it matters why a job is stopped?20:54
KeybukI'm thinking of only making the stop event environment available to the pre-stop script20:55
Keybuksince that script can decide to start the job again without killing the running process20:55
KeybukI don't think post-stop should get the environment, since it shouldn't care ?20:55
ion_Mm... I can’t think of any use cases immediately.20:55
ion_A post-stop script might e.g. want to send email based on the job’s exit value, or something.20:56
Keybukit should do that by hooking the stopped event ;)21:01
ion_Good point. :-)21:01
Keybuklet me dump my thoughts here21:08
Keybuk  start on foo or bar21:08
Keybuk  stop on wibble or wibble21:08
Keybuk  ... some job21:09
Keybukinitctl emit foo21:09
Keybukjob goal changed from stop to start21:09
Keybukjob state changed from waiting to starting21:09
Keybukjob state changed from starting to pre-start21:10
Keybuk  (pre-start run with UPSTART_EVENTS=foo)21:10
Keybukjob state changed from pre-start to spawned21:10
Keybuk  (main process with UPSTART_EVENTS=foo)21:10
Keybukjob state changed from pre-start to post-stop21:10
Keybuk(err, start)21:10
Keybukjob state changed from post-start to running21:10
Keybukok21:10
Keybukso the job is running, and the environment remained the same21:10
Keybuknow do21:10
Keybukinitctl emit wibble21:11
Keybukjob state changed from running to pre-stop21:11
Keybuk  (pre-stop run with UPSTART_STOP_EVENTS=wibble)21:11
Keybukjob state changed from pre-stop to stopping21:11
Keybuknow:21:11
Keybukinitctl emit bar21:11
Keybukjob goal changed from start to stop21:11
Keybukinitctl emit wobble21:11
ion_Don’t you mean from stop to start?21:11
Keybukyes, sorry21:12
Keybukmissed a line :p21:12
Keybukjob goal changed from start to stop21:12
Keybukwe're still in the right line here, we were just blocking on our stopping event21:12
Keybukso we're going to continue towards death21:12
Keybukjob state changed from stopping to killed21:12
Keybuk  (kill the main process)21:12
Keybukjob state changed from killed to post-stop21:12
Keybuk  (post-run run with UPSTART_STOP_EVENTS= ... errr...)21:12
Keybukie.21:12
Keybukif we attempt to run the post-stop with the environment from the stop events, that will be "wobble"21:12
Keybukyet pre-stop was run with "wibble"21:13
ion_Yep...21:13
Keybukwhich is wrong :)21:13
Keybukif script A, B and C are run with one set of environmen21:13
Keybukso should script D21:13
ion_Yep21:13
Keybukthe reason we don't have this problem on start events is because we can always run through stop first21:14
Keybukso we have the notion of the "next" start environment21:14
Keybukwherever we are in the cycle, we can skip running and run through the whole thing again, and switch over the environment next time we pass through starting21:14
Keybukthis isn't bad, since it appears like a restart, which given a stop/start sequence is exactly what you'd expect21:14
Keybukfor stop, we don't really want to run through start again, just so we can stop it again :)21:15
Keybukespecially if we know the stop event/state/etc. has already happened21:15
ion_Aye21:15
Keybukso that's my rationale for why only pre-stop should see the environment of the stop events21:15
ion_I don’t see a reason to disagree.21:16
Keybukin a sensible job, the stop events should be balanced by the start events21:16
Keybukso if you have tty-added...tty-removed as a pair, you can see tty-added in the post-stop script so assume that it was tty-removed that caused you to be stopped21:17

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