=== rberger_ is now known as rberger | ||
=== h\h is now known as haraldh | ||
Nikratio | Is 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 |
---|---|---|
sadmac2 | Nikratio: depends on what you want XX to be. | 15:58 |
Nikratio | I don't care about XX, I'll take whatever works. I want to start a job only if the hostname is my.host | 15:58 |
sadmac2 | Nikratio: its possible to do initctl emit fooevent HOSTNAME=$(hostname) from the command line to cause a fooevent with the current hostname | 15:58 |
sadmac2 | Nikratio: so if you plugged that into whatever script somewhere in the boot process you'd get an event named fooevent with the appropriate HOSTNAME value | 15:59 |
Nikratio | Ah, that sounds promising. What if my job depends not just on the event but also on something else? | 16:00 |
Nikratio | Do I have to make sure that (something else) is up before emitting the hostname event? | 16:00 |
sadmac2 | Nikratio: assuming you're using upstart 0.6, there's an "and" keyword for start on | 16:01 |
Nikratio | or will upstart "save" the event until the other conditions are fulfilled? | 16:01 |
sadmac2 | Nikratio: its kinda quirky though | 16:01 |
Nikratio | Yes, 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 |
sadmac2 | the 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 again | 16:02 |
Nikratio | hmmm. That's unfortunate... | 16:03 |
Nikratio | Is there any way to test against the hostname without using an event? | 16:08 |
sadmac2 | Nikratio: sure. pre-start exec [ "$(hostname)" == "my.host" ] || false | 16:09 |
sadmac2 | Nikratio: that should cause the job to fail to start if your hostname isn't my.host | 16:09 |
Nikratio | I 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 |
ion | UUOfalse | 16:27 |
ion | [ ... ] || stop should stop it gracefully. | 16:27 |
sadmac2 | Nikratio: he's right | 16:28 |
sadmac2 | ion: though I think we ran into some strange bugs recently trying things like that | 16:28 |
sadmac2 | I'll have to reproduce and file those sometime this week. | 16:28 |
Nikratio | ion: I don't understand. UUOfalse? What's got stopping to do with it? | 16:29 |
sadmac2 | Nikratio: if you have 'pre-start exec [ "$(hostname)" == "my.host" ] || stop' the job should gracefully not start rather than failing | 16:31 |
ion | Useless Use Of™. In sh with -e, ‘FOO’ is equivalent to ‘FOO || false’. I presented ‘FOO || stop’ as a graceful alternative. | 16:31 |
sadmac2 | ion: starting is emitted before pre-start, isn't it? | 16:31 |
sadmac2 | that could be an issue | 16:31 |
Nikratio | ion: 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 |
sadmac2 | Nikratio: when run from within an upstart job, the start and stop commands act on the job being run | 16:33 |
sadmac2 | Nikratio: i.e. with no arguments stop will examine $UPSTART_JOB to determine what to act on | 16:34 |
Nikratio | Neat.. But does stopping work in the pre-start script? | 16:34 |
ion | Why 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 |
sadmac2 | Nikratio: 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 |
Nikratio | Alright then. Thanks for your help! | 16:36 |
sadmac2 | np | 16:36 |
=== mbiebl_ is now known as mbiebl | ||
=== mbiebl_ is now known as mbiebl | ||
rberger | Is 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 |
ion | What do you need arrays for? | 21:57 |
rberger | ion: I need to loop thru a list of instances | 22:23 |
rberger | Is there an environment variable that gets set to the name of the event that triggered the "start on"? | 23:28 |
ion | UPSTART_EVENTS (init(5)) | 23:33 |
ion | I take it sh’s for loop isn’t enough? | 23:33 |
rberger | Thanks for the event info and also reminding me about init(5) for some reason I have a mental block remembering that. | 23:34 |
rberger | For the loop thing, I still need a list or an array to loop thru with the for loop | 23:38 |
rberger | Oh 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!