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