/srv/irclogs.ubuntu.com/2007/05/27/#upstart.txt

=== Keybuk [n=scott@wing-commander.netsplit.com] has joined #upstart
=== Keybuk had an interesting idea last night
AlexExtremeoh?12:38
Keybukconcerning how Status and Job interact12:39
Keybukso let's say we have a service that uses this:12:41
Keybuk  while interface-up until interface-down $IFACE12:41
Keybukthat defines a simple state period between an interface coming up and going down again12:41
Keybukthe state would keep a record of ALL interface-up events12:42
Keybukand ALL of them would have to be cancelled before the interface could go down12:42
Keybukie. that defines a service running while any network interface is up12:42
Keybuka simple modification:12:44
Keybuk  while interface-up until interface-down $IFACE12:44
Keybuk  instance12:44
Keybukthis job behaves differently; now each time an interface comes up, a new instance of the job is spawned, and that instance runs until the interface it was spawned for goes down12:44
Keybuksince states can be canned (and for other reasons) you'll want to be able to restrict which interfaces this is true for12:48
Keybukso you'd allow something like12:48
Keybuk  state interface-is-up12:48
Keybuk    while interface-up until interface-down $IFACE12:49
Keybuk  end state12:49
Keybuk--12:49
Keybuk  while interface-is-up ~lo12:49
=== Md [i=md@freenode/staff/md] has joined #upstart
Keybukthe other change to make is to Event12:56
KeybukI'm going to get rid of different positional and name-based variables12:56
Keybukinstead it's going to have just name-based ones, but in a particular order12:56
Keybukso an event might be12:56
Keybukstopping JOB=apache RESULT=failed FAILED_PROCESS=main12:57
Keybukand for matching in job definitions, you can omit the names in order until you give the first name12:57
Keybukbut the scripts won't receive any arguments, just them as environment variables12:57
AlexExtremeso we won't be able do have events like "interface-up eth0", instead it would be "interface up IFACE=eth0" ?12:58
Keybukyou cam omit the name provided eth0 is the first event in the list01:00
Keybuk(which it would be)01:00
Keybukin effect, they become like python method calls01:10
Keybukthis makes figuring out what to pass to the jobs MUCH easier ;)01:13
Keybuksince there's no worry about which gets $1, $2, etc. they all get arguments by name!01:13
Keybuklikewise01:13
Keybukinterface-up until interface-down $IFACE01:14
Keybukis more obvious than01:14
Keybukinterface-up until interface-down $101:14
AlexExtremeyes01:14
ion_Sounds good.01:18
Keybukion_: does the state/instance stuff make sense?01:24
ion_In what situations would counting the number of up events and waiting for the number of down events to match is necessary?01:26
ion_How about adding a new state to a running system  it would have no knowledge of recently emitted events it needs to track.01:28
ion_Oh, i misunderstood the intent. Ignore the In what situations... line.01:29
Keybuknot so much counting, but matching pairs01:29
Keybukand keeping track of which interfaces are still up01:29
ion_Yeah, i realized that. :-)01:29
Keybukit makes a lot of sense to have a service running while at least one network interface is up01:29
ion_Regarding the interface-is-up alias, id like the syntax to be more like: while interface-is-up IFACE=~lo until interface-down $IFACE, where the first part would be a fnmatch-ish match against the variable and the second part would match against the stored value.01:32
ion_Something like...01:32
ion_while interface-is-up IFACE=* until interface-down $IFACE01:33
ion_would be equivalent to01:33
ion_while interface-is-up IFACE until interface-down $IFACE01:33
ion_The difference to01:33
ion_while interface-is-up IFACE until interface-down IFACE01:33
ion_would be that any interface-is-up ... interface-down pair would match, since the IFACE value isnt compared to anything.01:34
ion_interface-down $IFACE would point to the value implicitly stored by interface-is-up IFACE01:34
KeybukI'm not sure I follow01:36
Keybukyou mean interface-up (an event) not interface-is-up?01:37
ion_Ah, sorry. I meant interface-up01:37
Keybukah, you mean name the variables on the left you intend to use on the right?01:37
Keybukinterface-up IFACE until interface-down $IFACE01:37
Keybuknot01:37
ion_Yes.01:37
ion_That would allow more complex matches, such as:01:37
Keybukinterface-up until interface-down $IFACE01:37
ion_while interface-up ADDR=10.0.0.* IFACE until interface-down $IFACE01:37
KeybukI don't see why the IFACE bit is needed?01:38
Keybukthat would work01:38
Keybukwhile interface-up ADDR=10.0.0.* until interface-down $IFACE01:38
Keybuk?01:38
ion_True. Just store all the variables by default, so that any of them could be matched against in the until part.01:39
ion_So IFACE would need to be mentioned in the first part *only* if its matched against something.01:39
ion_while interface-up IFACE=~lo until interface-down $IFACE01:40
ion_while interface-up until interface-down $IFACE01:40
ion_while interface-up ADDR=10.0.0.* until interface-down $IFACE01:40
ion_for example01:40
ion_Perhaps IFACE!=lo instead?01:41
Keybukyeah, either works doesn't it01:41
Keybukactually, I prefer !=01:41
ion_ADDR!=10.*01:41
ion_Anyway, that would remove the need to define a named alias just to be able to give patterns. Of course, aliases might be very useful for other purposes.01:43
Keybukthe named alias would be for complex things like "user-can-login"01:43
ion_Yeah01:43
Keybukif state allows spawning like this, then we could have structures like for loops in there01:44
Keybukfor PATH in `getmntent -fD` path-mounted $PATH until path-unmounted $PATH01:45
Keybuk:p01:45
ion_NEat.01:47
ion_Perhaps make it block-like01:48
ion_for PATH in $(getmntent -fD)01:48
ion_  while path-mounted $PATH until path-unmounted $PATH01:48
ion_end for01:48
Keybukthat could work too01:49
=== phoenix24 [n=phoenix2@59.176.23.106] has joined #upstart
ion_Another idea that accomplishes the same thing a bit differently: assign the output of getmntent -fD to an array variable, and do a single while expression that matches PATH to the array.01:50
ion_Also, an interface-up event might have multiple ADDR variables. It should be possible to match against any of them, or all of them.01:54
Keybukhow would you define/match that?01:54
ion_interface-up any(ADDR or(ADDR=127.* ADDR=::1)), where any would loop through ADDR variables and return true if any of the expressions return true. That syntax is ugly, though, but it can be improved. :-)01:58
ion_(any? ADDR (or ((match? ADDR "127.*") (match? ADDR "::1")))) ;-)02:00
ion_(all? ADDR (match? ADDR "*:*")) IPv6-only interface02:01
ion_Just like for foo in ADDR, do something with foo, but simplified to for ADDR, do something with ADDR, where inside the loop, ADDR is the value currently being iterated.02:05
ion_(blah ((mountpoints "getmntent -fD")) (any? mountpoints (eq? mountpoints PATH)))02:13
ion_Im definitely not saying thats what the syntax should be, just formulating ideas about how things could be matched.02:15
KeybukI've found lisp/scheme-like syntax easier to work things out in too02:22
Keybuksimply because it's already in the same shape as the necessary syntax tree to evaluate it02:22
Keybukrather than the latter02:23
Keybukuh, rather than the humanish way of putting it02:24
Keybukwhat does the mountpoints thing do?02:24
ion_Um, just assigns the output of the command to an array variable. Then the arrays compared to the PATH variable.02:27
ion_mountpoints.any? {|dir| env[:PATH]  == dir }  # Ruby syntax :-)02:27
=== Amaranth_ [n=travis@ubuntu/member/Amaranth] has joined #upstart
=== mbiebl [n=michael@p549cdf03.dip.t-dialin.net] has joined #upstart
=== penguin42 [n=dg@tu006.demon.co.uk] has joined #upstart
=== penguin42 yawns
penguin42I fancy adding a --host to the reboot/shutdown/halt utilities to check that the host you specify is the one you think you are trying to shut down03:56
penguin42I was also considering requiring it if it's run from a tty - anyone have strong views?03:57
Keybukheh03:58
Keybukinteresting patch ;)03:58
penguin42one too many halts of the wrong machine :-)03:58
penguin42I can't think of anything shorter than --host that would work on all of reboot/shutdown/halt04:00
Keybukyou'd need to give the hostname04:00
Keybukshutdown -h quest04:00
penguin42yeh exactly04:00
penguin42except shutdown already has a -h for example04:01
=== penguin42 will put something together - where is a good place to send the patch?
AlexExtremethe bug tracker at launchpad probably04:07
penguin42oh ok, I hadn't realised people used launchpad for patch stuff as well04:07
Keybukpenguin42: upstart-devel@lists.ubuntu.com04:09
Keybukor launchpad, yeah04:09
Keybukif you prefer, make a bzr branch of upstart and upload your branch to LP04:10
penguin42ok, I'll probably launchpad it since I've already got a launchpad account; probably just a patch for the moment unless I fancy figuring out the branch stuff04:11
Keybuk:)04:12
=== AlexExtreme loves bzr :P
Keybukyeah, it's not terrible04:20
penguin42is bzr yet-another-source-code-control thing?04:20
AlexExtremeyep04:22
penguin42Why does 'reboot' scan only ide discs to power them down?04:27
Keybukpenguin42: it doesn't even need to do that04:29
Keybukoriginally it was because the code was copied from sysvinit, and only ide disks existed then04:29
AlexExtremenow the kernel automatically does it04:30
penguin42ah ok04:30
penguin42reboot does seem to have a small random selection of clean up things in it04:31
Keybukyeah04:31
Keybukour goal is to eliminate both04:31
penguin42anyone good with man macros; .BR -m, --host \fI  HOST     doesn't seem to want to render a space before HOST05:37
KeybukI tend to just quote things05:38
penguin42that's still getting me  -m,--hostHOST05:41
Keybuk.BR -m ", " --host \fIHOST05:43
Keybuk?05:43
penguin42yeh but it's the space after '--host' I can't get to happen05:44
penguin42let me try a " "05:44
Keybuk"--host " ? :p05:44
penguin42yeh that's done it05:44
penguin42typesetter being too smart for its own good :-)05:45
penguin42ok, #117215 06:19
=== Keybuk [n=scott@wing-commander.netsplit.com] has joined #upstart
ion_I learned a new word from Futurama: oughtnt :-D12:15
cortanai learned "unpossible".... i don't think that's a real word tho12:17
Keybukheh12:21

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