/srv/irclogs.ubuntu.com/2010/02/22/#upstart.txt

=== rberger_ is now known as rberger
=== h\h is now known as haraldh
NikratioIs there a way to test against the hostname in a job's starting condition? I mean something like "start on XX hostname=my.host"15:55
sadmac2Nikratio: depends on what you want XX to be.15:58
NikratioI don't care about XX, I'll take whatever works. I want to start a job only if the hostname is my.host15:58
sadmac2Nikratio: its possible to do initctl emit fooevent HOSTNAME=$(hostname) from the command line to cause a fooevent with the current hostname15:58
sadmac2Nikratio: so if you plugged that into whatever script somewhere in the boot process you'd get an event named fooevent with the appropriate HOSTNAME value15:59
NikratioAh, that sounds promising. What if my job depends not just on the event but also on something else? 16:00
NikratioDo I have to make sure that (something else) is up before emitting the hostname event?16:00
sadmac2Nikratio: assuming you're using upstart 0.6, there's an "and" keyword for start on16:01
Nikratioor will upstart "save" the event until the other conditions are fulfilled?16:01
sadmac2Nikratio: its kinda quirky though16:01
NikratioYes, I know about the keyword. But I'm wondering how it works if the event is there but the other condition is not fulfilled yet. Will the job be started as soon as the other condition is fulfilled?16:02
sadmac2the and keyword saves the event, but the problem is it won't come back. so if you had start on foo and my_hostname_event, and then you stopped the job, you'd have to emit my_hostname_event again16:02
Nikratiohmmm. That's unfortunate...16:03
NikratioIs there any way to test against the hostname without using an event?16:08
sadmac2Nikratio: sure. pre-start exec [ "$(hostname)" == "my.host" ] || false16:09
sadmac2Nikratio: that should cause the job to fail to start if your hostname isn't my.host16:09
NikratioI guess that works, but I think it's rather crude. I don't want the job to fail, I want upstart not to start it 16:10
ionUUOfalse16:27
ion[ ... ] || stop should stop it gracefully.16:27
sadmac2Nikratio: he's right16:28
sadmac2ion: though I think we ran into some strange bugs recently trying things like that16:28
sadmac2I'll have to reproduce and file those sometime this week.16:28
Nikratioion: I don't understand. UUOfalse? What's got stopping to do with it?16:29
sadmac2Nikratio: if you have 'pre-start exec [ "$(hostname)" == "my.host" ] || stop' the job should gracefully not start rather than failing16:31
ionUseless Use Of™. In sh with -e, ‘FOO’ is equivalent to ‘FOO || false’. I presented ‘FOO || stop’ as a graceful alternative.16:31
sadmac2ion: starting is emitted before pre-start, isn't it?16:31
sadmac2that could be an issue16:31
Nikratioion: I see. So the pre-start script executes the "stop" command if it's on the wrong host. But what is the stop command supposed to stop? 16:32
sadmac2Nikratio: when run from within an upstart job, the start and stop commands act on the job being run16:33
sadmac2Nikratio: i.e. with no arguments stop will examine $UPSTART_JOB to determine what to act on16:34
NikratioNeat.. But does stopping work in the pre-start script?16:34
ionWhy do you need this check, btw? Whatever you’re deploying to multiple boxes, can’t the deployment tool install stuff conditionally for each box?16:35
sadmac2Nikratio: it should. Like I said, I've seen some strange bugs in that area, but if it doesn't work you can file it :)16:36
NikratioAlright then. Thanks for your help!16:36
sadmac2np16:36
=== mbiebl_ is now known as mbiebl
=== mbiebl_ is now known as mbiebl
rbergerIs DASH the only shell or other scripting language available in the pre-start script section of an upstart job description?. I need arrays. Do I just call out to an external scripting language?21:55
ionWhat do you need arrays for?21:57
rbergerion: I need to loop thru a list of instances 22:23
rbergerIs there an environment variable that gets set to the name of the event that triggered the "start on"?23:28
ionUPSTART_EVENTS (init(5))23:33
ionI take it sh’s for loop isn’t enough?23:33
rbergerThanks for the event info and also reminding me about init(5) for some reason I have a mental block remembering that.23:34
rbergerFor the loop thing, I still need a list or an array to loop thru with the for loop23:38
rbergerOh I guess it treats  items in a string with space separations like a list... 23:44

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