/srv/irclogs.ubuntu.com/2008/04/19/#upstart.txt

Keybukmorning11:38
Keybukion_: around?11:38
* Keybuk needs to bounce an idea off someone :p11:49
ion_keybuk: Yeah13:15
Keybukion_: so I've been thinking about the whole problem of job environment13:15
Keybuklet's use the getty job as an example13:15
Keybuk  env SPEED 3840013:16
Keybuk  instance $TTY13:16
Keybuk  exec /sbin/getty $SPEED $TTY13:16
Keybukwe can fire off a couple of these for the system consoles13:16
Keybuk  start getty TTY=tty113:16
Keybuk  start getty TTY=tty213:16
Keybuk  start getty TTY=tty313:16
Keybukand we can figure up one for a slower serial console13:16
Keybuk  start getty TTY=ttyS0 SPEED=1440013:16
Keybukenvironment from the start request overrides that from the job definition, so env sets "defaults"13:17
Keybukso that all works nicely13:18
Keybuknow, what happens when another job uses those events13:18
Keybuk  start on started getty13:18
Keybukwhich getty?  there's lots of gettys running13:18
Keybukwe do have the INSTANCE variable in that event we could use13:18
Keybuk  start on started getty INSTANCE=tty113:19
Keybukand that happens to work for this13:19
Keybukso using a different example, the dbus session bus daemon service13:20
Keybuk  instance $USER13:20
Keybuk  exec /sbin/dbus-daemon --session13:20
Keybuk  env DBUS_SESSION_BUS_ADDRESS=...13:20
Keybukanother job might do13:20
Keybuk  start on started dbus-session-bus13:20
Keybukbut it doesn't have access to the session bus address13:21
ion_Yeah13:21
Keybuksince it exists in the job environment of the dbus-session-bus job13:21
Keybukand isn't in the starting/started/stopping/stopped events13:21
Keybukeven getty starts to have a useful example13:21
Keybuk  start on starting getty TTY=ttyS*13:21
Keybuk  exec setserial $TTY $SPEED13:22
Keybuksuddenly we have a case where we might want to run setserial if we're starting a getty with a particular $TTY (rather than just instance name) and want the speed13:22
Keybukso I was thinking about adding the whole job environment to the events13:23
Keybukbut I don't think that works at all13:23
Keybukin particular, if the job's started on a failed event, any job starting on that would be indistinguishable from the same failed event info13:23
Keybukand it just leads to massive environment creep13:23
Keybukso what I came up with was:13:24
Keybuk  env SPEED=3840013:24
Keybuk  instance $TTY13:24
Keybuk  export TTY SPEED13:24
Keybuk  exec /sbin/getty $SPEED $TTY13:24
Keybukie. a job definition can "export" some of its environment13:24
Keybukand those are the variables that will be added to its starting/started/stopping/stopped events automatically13:24
ion_Looks good13:24
Keybukdo you think that's better than exporting nothing or exporting everything?13:25
ion_Exporting everything would work, too, if the other jobs acting on those events can select what to import instead of having their environment polluted.13:26
Keybukyeah, but I couldn't think of a good syntax from that13:26
Keybukand that would start to mean you need to declare import for everything13:26
ion_Yeah13:26
Keybukstart on tty-added13:27
ion_What you proposed seems good to mee.13:27
ion_me13:27
Keybukstop on tty-removed TTY=$TTY13:27
Keybukimport TTY from tty-added13:27
Keybuk(you'd need the latter to be consistent)13:27
KeybukI kinda like the fact that if you mention an event, you automatically get its environment13:27
Keybukand having consistency between what you can match on and what you can use is nice too13:27
ion_Yeah13:28
Keybukof course, _now_ I notice a problem with taking away job ids14:25
Keybukjobs with just "instance" can't be uniquely dealt with14:25
* Keybuk tries to think of a reason to support unlimited instance jobs15:08
Keybukcan't think of a good one15:23
Keybukif people really want them, they can just do something like15:23
Keybukinstance $UUID15:23
Keybukstart job UUID=$(uuidgen)15:23
ion_Yeah15:31
Keybukafter racking my brain I can't think of _any_15:33
Keybukif it acts on an event, it needs at least one environment variable to know what to do15:33
Keybukif it acts on a device or path, it can instance on that15:33
Keybukif it writes to the disk, it needs to instance on that path15:33
Keybuketc.15:33
Keybukunlimited instance jobs inherently can't lock anything, or have any side-effects15:34
Keybukand I can't think of anything like that15:34
ion_Yeah, i can’t think of one either.15:38
Keybuksweet17:00
KeybukI just worked out something that will now work17:01
Keybukassuming that telinit places $RUNLEVEL and $PREVLEVEL in the runlevel event, and sets utmp/wtmp (which is the plan)17:01
Keybuk/etc/init/jobs.d/rc:17:01
Keybuk    start on runlevel17:01
Keybuk    stop on runlevel [!$RUNLEVEL]17:01
Keybuk    17:02
Keybuk    export RUNLEVEL17:02
Keybuk    17:02
Keybuk    console owner17:02
Keybuk    session leader17:02
Keybuk    exec /etc/init.d/rc $RUNLEVEL17:02
Keybukrather than having rc2,3,4,5, etc.17:03
ion_Nice17:07

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