/srv/irclogs.ubuntu.com/2007/02/11/#upstart.txt

_ionDoes anyone know which tool Keybuk uses for keeping the ChangeLog file updated in bzr?02:21
=== theCore [n=alex@ubuntu/member/theCore] has joined #upstart
=== j_ack [n=rudi@p508D8BB1.dip0.t-ipconnect.de] has joined #upstart
_ionPhew. Today was one of the few days of a year when i actually manage to get some code done despite my health issues. I wrote http://soijabanaani.net/tmp/nih_watch_delayed.diff04:26
_ionWriting that took like ten times the time it would have taken if i could concentrate normally.04:26
_ionHere's also a small parenthesis fix, http://soijabanaani.net/tmp/nih_hash_foreach_parenthesis.diff04:27
=== Amaranth [n=travis@ubuntu/member/Amaranth] has joined #upstart
=== peeps [n=peeps@cpe-70-112-25-110.austin.res.rr.com] has joined #upstart
=== peeps [n=peeps@cpe-70-112-25-110.austin.res.rr.com] has left #upstart ["Leaving"]
=== Amaranth [n=travis@ubuntu/member/Amaranth] has joined #upstart
=== j_ack [n=rudi@p508D8BB1.dip0.t-ipconnect.de] has joined #upstart
=== theCore [n=alex@ubuntu/member/theCore] has joined #upstart
=== AlexExtreme [n=AlexExtr@frugalware/developer/AlexExtreme] has joined #upstart
=== int0x0c [n=ben@161.253.46.23] has joined #upstart
=== wasabi [n=jhaltom@ubuntu/member/wasabi] has joined #upstart
=== Seveas [n=seveas@ubuntu/member/seveas] has joined #upstart
=== wasabi_ [n=wasabi@ubuntu/member/wasabi] has joined #upstart
=== jonibo [n=jonas@213.212.2.215] has joined #upstart
=== _ion [i=johan@kiviniemi.name] has joined #upstart
=== popey [n=alan@ubuntu/member/popey] has joined #upstart
=== j_ack_ [n=rudi@p508DA30C.dip0.t-ipconnect.de] has joined #upstart
=== jonib1 [n=jonas@ua-83-227-144-18.cust.bredbandsbolaget.se] has joined #upstart
=== phsdv [n=paul@dyn-83-152-239-92.ppp.tiscali.fr] has joined #upstart
phsdvint0x0c, are you trying to get upstart going on gentoo?11:30
=== juergbi [n=juerg@80-219-17-102.dclient.hispeed.ch] has joined #upstart
phsdvI just uploaded an ebuild for 0.3.5 into gentoo bugzilla (http://bugs.gentoo.org/show_bug.cgi?id=150190) 11:45
=== Md [i=md@freenode/staff/md] has joined #upstart
=== phsdv [n=paul@dyn-83-152-239-92.ppp.tiscali.fr] has joined #upstart
=== Cubano [n=jens@0x55510128.adsl.cybercity.dk] has joined #upstart
=== Keybuk [n=scott@wing-commander.netsplit.com] has joined #upstart
Keybukso, I came up with a neat idea ...03:09
Keybukyou know how we have emits ?03:09
Keybukthat'd be a really nice way of defining special events03:09
Keybukjob lists the event names with the emits stanza03:10
Keybukand when started, sends a message to upstart saying that it wants active notification of registrations03:10
Keybukupstart sees it's from a pid of a known job, that has listed emits stanzas03:10
Keybukso sends the job back as a reply every use of "on THAT-EVENT"03:10
Keybukand whenever new jobs are registered, or jobs are deleted, keeps that process up to date03:10
Keybuke.g.03:11
Keybuka job called "inetd"03:11
Keybukemits tcp udp03:11
Keybukconnects to upstart03:11
Keybukand receives information that there are jobs with03:11
Keybukon tcp 8003:11
Keybukon udp 5303:11
Keybuketc.03:11
Keybukso it knows to listen on those ports, and knows to emit events with those arguments03:11
AlexExtremesounds good03:12
AlexExtremeso, there's most of the work for replacing inetd done? :P03:14
Keybukit means you can take exotic events out of the core03:16
Keybukdon't want inetd support?  don't run upstart-ientd03:16
AlexExtremeyes03:16
Keybukuseful for the dbus proxy too03:17
Keybukon dbus com/redhat/dhcp/eth0 com.redhat.dhcp.down03:17
Keybukso it'd know to listen to that signal, and emit that evnet03:17
=== j_ack [n=rudi@p508D92A9.dip0.t-ipconnect.de] has joined #upstart
_ionkeybuk: Ooo, really nice idea.04:06
_ionkeybuk: Any comments about the watch_delayed thing?04:06
KeybukI looked at the code, and it looked pretty good04:07
Keybukhaven't had a chance to test it yet; want to get complex-event done today since we want that asap04:07
_ionAll right.04:07
Keybukwill look at it properly this week : )04:08
_ionYou might want to include nih_hash_foreach_parenthesis.diff immediately though, it fixes a bug. :-)04:09
Keybukyeah, I saw that04:10
Keybukthanks!04:10
Keybukcan you paste me a changelog for that one04:10
_ion        * nih/hash.c (NIH_HASH_FOREACH, NIH_HASH_FOREACH_SAFE): Added missing parenthesis.04:12
_ionIs that enough? :-)04:12
_ionDuh, nih/hash.h, not .c04:13
_ionWhat tool do you use to maintain the changelog and have it integrated with bzr commits, btw?04:13
_ionA bzr plugin?04:13
Keybuka shell script04:14
_ionIs it available for downloading? :-)04:15
Keybukhttp://people.ubuntu.com/~scott/software/bzr-commit04:15
_ionThanks04:15
KeybukI maintain the ChangeLog first using emacs (C-x 4 a)04:15
Keybukand then just use that to do the commits, with the changelog diff04:16
Keybukactually -- can you commit your watch delayed stuffa04:16
Keybukand push it to a branch of your own?04:16
Keybuksomething like04:18
_ionActually i did commit it to a branch of my own in the first place, but decided just to send a diff because i hadn't written changelog entries or commit messages using the format you use in your repository. I'll do that now, using that script. :-)04:18
Keybukbzr push sftp://ion@bazaar.launchpad.net/~ion/libnih/watch-delayed04:19
KeybukI think is the format04:19
Keybukthat should automatically register it on https://code.launchpad.net/libnih04:19
=== mbiebl [n=michael@e180118213.adsl.alicedsl.de] has joined #upstart
_ionkeybuk: https://code.launchpad.net/~ion/+branch/libnih/watch-delayed04:52
Keybukexcellent04:54
Keybukwing-commander scott% ./parse "foo bar baz until frodo bilbo and eep"04:54
KeybukOperator (AND)04:54
Keybuk    Event ("eep")04:54
Keybuk    Operator (UNTIL)04:54
Keybuk        Event ("frodo", "bilbo")04:54
Keybuk        Event ("foo", "bar", "baz")04:54
Keybuk\o/04:54
Keybuknow to figure out whether I've got the precedence right :p04:54
_ion\o/04:54
Keybukwing-commander scott% ./parse "foo until bar and frodo until bilbo"04:55
KeybukOperator (AND)04:55
Keybuk    Operator (UNTIL)04:55
Keybuk        Event ("bilbo")04:55
Keybuk        Event ("frodo")04:55
Keybuk    Operator (UNTIL)04:55
Keybuk        Event ("bar")04:55
Keybuk        Event ("foo")04:55
_ionkeybuk: You should be able to pull the nih/hash.h fix and nothing else by running bzr merge --pull -r 386 http://bazaar.launchpad.net/~ion/libnih/watch-delayed, i think.05:10
_ionThe actual delayed watch code is in revno 387.05:11
Keybukwing-commander scott% ./parse "set timer until (boom or kaboom)" 05:12
KeybukOperator (UNTIL)05:12
Keybuk    Event ("set", "timer")05:12
Keybuk    Operator (OR)05:12
Keybuk        Event ("boom")05:12
Keybuk        Event ("kaboom")05:12
Keybuk\o/05:12
_ion\/05:13
AlexExtreme:)05:13
_ionkeybuk: Have you decided a name for the complex-event-spec stanza yet? :-)05:13
Keybukwing-commander scott% ./parse "fhs-filesystem-mounted until fhs-filesystem-down and network-up until network-down"05:14
KeybukOperator (AND)05:14
Keybuk    Operator (UNTIL)05:14
Keybuk        Event ("fhs-filesystem-mounted")05:14
Keybuk        Event ("fhs-filesystem-down")05:14
Keybuk    Operator (UNTIL)05:14
Keybuk        Event ("network-up")05:14
Keybuk        Event ("network-down")05:14
Keybuk_ion: nope05:14
Keybukwing-commander scott% ./parse "with apache or with thttpd"05:22
KeybukOperator (OR)05:22
Keybuk    Operator (WITH)05:22
Keybuk        Event ("apache")05:22
Keybuk    Operator (WITH)05:22
Keybuk        Event ("thttpd")05:22
Keybukyay05:22
Keybukeven unary works05:22
_ionWhee05:22
_ionD'oh, i wrote "patch change events" to the changelog entry. :-)05:23
Keybukoops05:24
Keybukok, I think the parser works05:26
Keybukgot to make config respect parens as newline escapers, then try and recodify my ugly quick C into a stanza parser05:27
Keybukinteresting question05:49
Keybukshould this:05:49
Keybuk  FOO blah and (blah until blah       # some comment05:49
Keybuk                or blah until blah)05:49
Keybukbe valid05:49
Keybuk(ie. comment inside parens05:49
_ionI don't see why not. Someone might want to do something like this, while testing something:05:50
Keybukit's kinda unique in the format, since nothing else uses parens05:50
_ionFOO something something (something # comment out the rest of the line, something something05:50
_ion                         # comment out also this part, something something)05:51
_ion                         new stuff)05:51
Keybukand I do think not being required to escape newlines inside parens is useful05:51
=== AStorm [n=astralst@host-81-190-179-124.gorzow.mm.pl] has joined #upstart
AStormHello.06:06
=== arachnist [i=arachnis@paludis/monkey/arachnist] has joined #upstart
Keybukhey AStorm06:06
Keybuk_ion: merged 38606:06
AStormI've ran upstart on Gentoo, basic compatibility right now06:07
AStorm(running large /sbin/rc, and requires a small modification of one script)06:07
Keybuksweet, do you have the details of what needs to be done?06:07
AStormI'm developing a fully event-based init system for it.06:07
Keybukplanning to ship some example jobs in the upstart tarball directly with the next version, would be cool to have a gentoo subdir in there06:07
AStormAnd I've some questions, esp. regarding mounting06:07
Keybuksure06:07
AStormIs there something like stop for these?06:08
AStormLike the default plain exec is start06:08
AStormthen stop would be ran on stopping.06:08
Keybuksorry, not sure I understand06:08
AStormOr do I have to use post-stop?06:08
AStormYou know, I don't want to split the event in two.06:08
Keybukoh, I see what you mean06:09
Keybukupstart's jobs aren't quite analogous to init scripts06:09
AStorm(could do this with unmount-dev script for "on stopped mount-dev")06:09
AStormI'd rather have it called directly in one script.06:09
Keybukyou can do it one of two ways06:09
AStormCan do this in post-stop right now...06:09
Keybukhave two jobs, mount and unmount06:09
AStorm(or in pre-stop)06:09
Keybukone that mounts things, one that unmounts them06:09
AStormBut it feels unclean.06:09
Keybukand have them otherwise unrelated06:09
Keybukor06:10
Keybukyou can have them in one job06:10
AStormrelated related06:10
Keybukif you have them in one job, put the mount stuff in pre-start06:10
Keybukand the unmount stuff in post-stop06:10
AStormBy the unmount one would dep "on stopped mount-dev"06:10
Keybukand don't have an exec or a script06:10
Keybukthe job would appear to be "running" all the time the disk is mounted06:10
AStormExactly.06:10
Keybuk(note that there's a sliiight bug there atm)06:10
AStormBug? What kind of?06:11
Keybukit won't ever actually stop06:11
AStormhmm.06:11
Keybukit slipped in at the last minute yesterday before I released 0.3.506:11
AStormRight, because it's no daemon and there's no SIGCHLD, right?06:11
KeybukI didn't have a good enough test case for it06:11
AStormFunny bug. So, for now, I'll split the script.06:11
Keybukright; because when the stop event comes in, it will only change the goal to stop -- and won't force a state change06:12
AStormFunny.06:12
Keybukthis worked a few days ago06:12
AStormNot a problem with me, but with the users...06:12
AStormNow to unmount the device, they'd have to "start" the unmount06:13
AStormnot stop the mount :-) A bit illogical.06:13
Keybukwould you have one job per mounted disk, or one job for all of fstab ?06:13
AStormRather the first one06:13
Keybukright 06:13
AStormBut the job would work using an argument.06:13
Keybukfor the first one, you'd do something like:06:14
Keybuk   instance06:14
Keybuk   start on block-device-added06:14
Keybuk   stop on block-device-removed06:14
Keybukor something06:14
AStormYes, something like that probably.06:14
Keybukthe instance bit is important, it tells upstart that multiple copies can be running06:14
AStormBut right now, it's /dev mounting, which is doubly funny06:14
Keybuk(temporary fix06:14
Keybukrather than splitting into two jobs, just have a dummy script06:14
AStormAha, nice, undocumented.06:14
Keybukpre-start script06:15
Keybuk   # mount stuff06:15
Keybukend script06:15
AStormFine, very fine.06:15
Keybukpost-stop script06:15
Keybuk   # unmount stuff06:15
Keybukend script06:15
AStormI know. the bug is just when I exec something, right?06:15
AStorm(in full start)06:15
Keybukscript06:15
Keybuk   while true; do sleep 1000; done06:15
Keybukend script06:15
_ionsleep inf06:16
Keybukthe script...end script will mean that there's a process running while the disk is mounted06:16
Keybuk_ion: does that work? :p  neat06:16
Keybukexec sleep inf06:16
Keybuk:p06:16
_ionIt works with GNU sleep, but not with e.g. the BSD one.06:17
AStormKeybuk, uh, a bit evil hack, but temporarily I'll do that.06:17
Keybukthen this week, when I fix that bug, you can drop the sleep :p06:17
AStorm_ion, not a problem here, it's Gentoo and it's temporary.06:17
AStormGood, very good.06:18
Keybukthe bug is that it won't force a state change out of running if there's no pid; because the child reaper calls job_change_goal and doesn't want a state change as a side-effect06:18
AStormThe major thing will be forcing udev to generate events06:18
AStormthe default rules don't do that06:18
Keybukthis turns out to be wrong, simply because the child reaper actually does want to force a state change as a side-effect :p06:18
Keybukso all I need to is fix the child reaper, and remove the bogus check from job_change_goal06:18
Keybukneed to write some test cases for it first though06:18
AStormJust check the state06:19
AStormafter running some echo in pre-start06:19
AStormand something else in post-stop06:19
AStorm(e.g. some file write), then check if the file was written06:19
AStormWithout any exec inside.06:19
AStormI wonder if initctl stop thatservice would hang06:20
Keybuksorry?06:21
AStormThe state would change properly to stopping?06:21
AStormIs it just that the task doesn't enter "waiting" state?06:21
AStormor something else totally?06:22
AStormOr just that it finishes too early?06:23
Keybukpost-stop gets run in stopping06:24
Keybukand then it should go to waiting06:24
Keybukinitctl hangs is probably the bug06:25
AStormHmm, the test would be quite hard.06:27
AStormBecause of the hang, you'd have to use shell job control with some timeout.06:27
AStormdamned halting problem, eh? :P06:29
phsdvAStorm, I have made an ebuild for 0.3.5 (in bugzilla). If you needs some help with your new scripts on gentoo, pls let me know06:34
AStormWell, the help would be wrt making udev send upstart events06:35
AlexExtremethat's easy06:36
AStormI've overwritten my init with upstart currently, have the stupid way of compatibility (running full gentoo init) working06:36
AStormAlexExtreme, so then, describe it to me, I'd be grateful.06:36
KeybukAStorm: RUN+="initctl emit some-event"06:36
phsdvACTION=="add",    SUBSYSTEM=="block", KERNEL=="*[!0-9] ", RUN="/usr/sbin/initctl emit block-device-added %k"06:37
AStormI'm not a master of init rules...06:37
AlexExtremedamn06:37
AlexExtremebeat me to it :)06:37
AStormphsdv, ok, so simple :-)06:37
AStormSo I'll have to also do a package of udev rules - expected that.06:37
phsdvI had them ready... wrote them a while ago06:37
Keybukphsdv: add "-eDEVNAME" to that06:37
phsdv-eDEVNAME?06:37
AStormphsdv, could you mail them to me then? (or put somewhere I can get them)06:37
AStormThe parameter, you know06:38
AStormor environment variable DEVNAME06:38
Keybukphsdv: put the DEVNAME environment variable in the environment of any job run by the block-device-added event06:38
_ion-eBAR without =quux grabs the value from the current environment? Nice.06:38
AStormGreat. It's so bad the upstart is so undocumented yet :-)06:38
phsdvACTION=="remove", SUBSYSTEM=="block", KERNEL=="*[!0-9] ", RUN="/usr/sbin/initctl emit block-device-removed %k"06:38
phsdv^ same for remove 06:39
AStormphsdv, I know, I know.06:39
KeybukAStorm: heh, I do have "document it" high on the TODO list06:39
Keybukthough remember, a lot of the features you're using today were only written in the last week <g>06:39
=== j_ack_ [n=rudi@p508DB9F4.dip0.t-ipconnect.de] has joined #upstart
AStormKeybuk, hehe, I'll do something like that06:39
AStormwhen I finish full gentoo init script compat06:39
AStormwhich will consist of modified depscan.sh and runscript.sh06:39
AStorm(to store the dependencies in upstart scripts)06:40
AStormMaybe also some mapping, like: net="network-device-eth0:network-device-eth1"06:40
AStormThe hardest part will be deps of type "use"06:42
AStormThe script would have to check the list of added services (simple, right :P )06:42
AStormKeybuk, is it possible to parametrise the dependencies, so I don't have to generate scripts?06:43
AStormAs in the dependency would be a parameter, some environment value?06:43
_ionWell, you could do as Ubuntu does: keep the old compatibility layer there and gradually rewrite things from the old system to upstart.06:43
AStormI'm just thinking about that.06:44
AStormJust moving the most basic layer to upstart now06:44
AStormand write the compat script06:44
AStormKeybuk, so, is that possible? To base "dependencies" (events I want get started on) on the environment variable or a parameter?06:45
mbieblAStorm: What about documenting your work on the wiki?06:45
mbieblhttp://upstart.ubuntu.com/wiki/UpstartOnGentoo06:45
AStormI'll do that :-)06:45
AStormWhen I have something working, I'll do an ebuild and document it.06:45
mbieblGreat, seems as many gentooers are already playing with upstart and there is much duplicated effort.06:46
AStormNot a lot, though.06:46
AStormUpstart is so nice, the amount of "work" required is low.06:47
AStorm(except that possible conversion script - that requires a tiny bit of bash-fu)06:47
KeybukAStorm: I'm not sure I understand what you mean?06:48
AStormKeybuk, like that:06:48
AStormThere is an event send, let's call it run-me06:48
AStormIt is emitted with an unknown number of parameters: abc def ghi06:49
AStormAnd I want to have them converted to: on abc and on def and on ghi06:49
AStormMaybe a tiny extension of the syntax - explicit and?06:50
AStormand support for environment vars in calculation of the events/06:50
Keybukso you have06:51
AStormE.g. I could do: initctl run-it DEPS="abc def ghi"06:51
Keybuk  "run-me abc def ghi"06:51
AStormand do: on $DEPS06:51
Keybuk?06:51
AStormI don't have that yet :-)06:51
KeybukI'm still trying to understand what you're trying to do, I'm afraid06:51
AStorms/initctl/initctl emit/06:51
=== Keybuk has never seen the Gentoo init system
AlexExtremeit's *very* complicated :)06:52
AStormKeybuk, it's a simple "need" based system06:52
AStormAlexExtreme, not really06:52
AStormWith some "after and before"06:52
Keybukso when a job starts, it causes the jobs it needs to also be started?06:52
AlexExtremeit seemed that way to me :P06:52
AStormKeybuk, exactly.06:52
Keybukor is it the kind where a job is not started until everything it needs has been started by something else?06:52
AStormLike that old "depend" trick06:52
AStormWhich was obsoleted some time ago06:53
AStormKeybuk, the second one rather06:53
Keybukin upstart, if "FOO" needs "BAR" then in FOO's job file, you would write:06:53
Keybuk    start on started FOO06:53
Keybuk    stop on stopping FOO06:53
AStormExactly.06:53
Keybukerr06:53
Keybuks/FOO/BAR/ in that :p06:53
AStormAnd I'd add in the main one: start on gentoo06:53
AStormand stop on gentoo06:54
AStormthat one would emit proper events to run things06:54
Keybukin the main one?06:54
AStormSomething like that, right.06:55
Keybukmain what?06:55
AStormA conversion of Gentoo init to rcS, so it seems.06:55
AStormIt's just that the script "gentoo" would call the wrapper for gentoo-style init multiple times06:55
Keybukmaybe I need to rewind here06:55
Keybukare you wanting to know how to rewrite current init scripts into upstart native jobs ...06:55
AStormand this wrapper would get the deps right (precalculated by script)06:56
Keybuk... or are you trying to find out how to write a generic job that can start any gentoo init script ?06:56
AStormKeybuk, the last one06:56
Keybukaha!06:56
Keybukright, basis of my confusion here then :p;06:56
AStormThis would simulate gentoo runlevels.06:56
AStormand the smaller script would just launch things06:57
Keybukwell, at the most basic level, you need a job that handles the simple case of starting, running and stopping one job06:57
AStormExactly, but with parametrised deps06:57
Keybukideally, that would need to spawn the job in the pre-start script, and then kill it again in the post-start script06:57
AStormBut then, I'd need a wildcard06:57
Keybukand somehow wedge in the running state while the job is actually running06:57
AStormYes.06:58
Keybukfirst you need to write the job, without any deps06:58
Keybukyou could do it all in "script" in fact06:58
Keybukscript06:58
Keybuk   /etc/init.d/$JOB start06:58
AStormExactly06:58
AStormThat's what I want...06:58
Keybuk   while [ -f /var/run/$JOB.pid ] ; do sleep 1; done06:58
AStormbut for deps I'd need to match on the JOB variable06:58
Keybuk   /etc/init.d/$JOB stop06:58
Keybukend script06:58
AStormNo pidfile support06:58
Keybukthough that's not quite right, since stopping the upstart job would not stop the gentoo one06:58
Keybukwhat I might do there is06:59
AStormGentoo is using the pids itself in the scripts06:59
Keybukpost-start script06:59
Keybuk    /etc/init.d/$JOB start06:59
Keybukend script06:59
Keybukscript06:59
AStormJust call /etc/init.d/$JOB stop06:59
AStormYes, that's it.06:59
Keybuk    while /etc/init.d/$JOB is-running; do sleep 1; done06:59
Keybukend script06:59
Keybukpre-stop script06:59
Keybuk    /etc/init.d/$JOB stop06:59
Keybukend script06:59
AStorm"is-running" is impossible yet. Just sleep instead :P06:59
Keybukright, but how do you know if someone stops the job when you weren't looking? :p06:59
Keybukif you don't care, then omit the "script ... end script" bit07:00
AStormWell...07:00
Keybuk(and replace with exec sleep inf until I fix this bug)07:00
AStormExactly, don't care.07:00
Keybukok07:00
AStormStupidity is not rewarded :P07:00
Keybukso this gives you a job that will start and stop any gentoo job when it, itself, is started and stopped07:00
AStormAnd init scripts are disallowed to call stop on others explicitly07:00
AStorm(Gentoo policy)07:00
Keybukof course, you need to mark this "instance" because you want multiple copies running07:00
AStormYes.07:00
AStormBut I need a match on $JOB07:00
Keybuknow, you'll want an event to start up an instance for a given job07:01
Keybukand another event to stop an instance for the same job07:01
Keybukeasiest way to define that07:01
AStormto start its deps earlier07:01
Keybukinitctl emit gentoo-start -eGENTOO_JOB=NAMEOFJOB07:01
Keybukinitctl emit gentoo-stop -eGENTOO_JOB=NAMEOFJOB07:01
AStormYes.07:01
Keybukso stick in the gentoo job file07:01
Keybukstart on gentoo-start07:01
Keybukstop on gentoo-stop07:01
AStormBut then, the deps are to be given as the parameters still07:01
AStorm(because of the need system)07:01
Keybukand use $GENTOO_JOB throughout07:01
AStormor the single script won't work07:01
Keybuk(getting to dependencies)07:01
AStormCan I do a match like:07:02
AStormon gentoo-start GENTOO_JOB=xyz *07:02
Keybukno07:02
AStormor would the DEPS variable be ignored?07:02
AStorm(if I don't match on it)07:02
Keybukquestion07:02
Keybukhow would you like deps to be handled?07:02
Keybukif you start FOO, should it cause its deps to be started?07:03
AStormYes.07:03
Keybukright07:03
AStormand then foo itself.07:03
Keybukso now we improve the "gentoo-start" event07:03
AStormYep.07:03
Keybukinitctl emit gentoo-stop -eGENTOO_JOB=NAMEOFJOB -eGENTOO_DEPS="dep1 dep2 dep3 dep4"07:03
Keybukuh07:03
Keybuks/-stop/-start/ :p07:03
AStormNot a problem.07:03
Keybuknow that instance, when it gets started, has $GENTOO_JOB which is the job we actually want to run07:03
Keybuk(used in post-start and pre-stop)07:04
AStormI'd love to avoid parsing the GENTOO_DEPS though. there's no way yet, right?07:04
AStorm(like just putting on started $GENTOO_DEPS)07:04
AStormOr rather:07:04
AStormwhen $GENTOO_DEPS07:04
Keybukand that instance also has $GENTOO_DEPS07:04
Keybukso the simplest way is to add07:04
Keybukpre-start script07:04
AStormwhich would expand to when dep1 and when dep2 and when dep307:04
Keybuk   for DEP in $GENTOO_DEPS; initctl emit gentoo-start $DEP; done07:04
Keybukend script07:04
Keybukthat wouldn't do what you want07:05
Keybukthat would emulate the second kind of system07:05
AStormIt would do it too :-)07:05
AStormAh, right.07:05
AStormthe need would add when07:05
AStormthe use would add on07:05
AStorm:-)07:05
AStormthat's the catch07:05
AStormOr even better.07:05
AStormuse would still add when07:05
AStormafter would add on07:05
Keybukerr?07:05
AStormbefore would work like after, but backwards07:06
AStormGentoo has 4 kinds of deps:07:06
Keybuknope, completely lost me07:06
AStormneed, use, before and after07:06
AStormneed means a hard dependency07:06
Keybukneed implies that if you try and start $JOB, then its dependencies come up first07:06
AStormso we should get restarted when the dependency is07:06
Keybuk?07:06
AStormYes07:06
AStormBut also when you restart that dependency, the package itself is restarted too. Like when07:07
AStormuse is like when, but optional - that's only a problem for dependency precalculator, to see if the thing is added to the runlevel and add the dep then07:07
Keybukok07:07
AStormafter and before are for ordering, doable using on.07:08
Keybukrandom thought; I wouldn't pass $UPSTART_DEPS as part of the evnet07:08
Keybuks/UPSTART/GENTOO/07:08
Keybukin the pre-start script, I'd parse the gentoo init script to get them07:08
AStormHmm...07:08
Keybukthat way you don't need to duplicate code everywhere07:08
AStormAnd add the aliases there too?07:08
Keybukright07:08
AStormWould be very fat.07:08
AStormBad idea.07:08
AStormI can precalculate them.07:09
Keybukyeah, but you have a single job then which handles the entire case of starting and stopping a gentoo init script07:09
Keybukand just needs the name07:09
Keybukrather than trying to duplicate the code everywhere07:09
AStormYes.07:09
Keybukyou'd need the "extract list of deps" code in several places, otherwise07:09
AStormBut parsing is slow.07:09
AStormI want to avoid this slowness by parsing once.07:09
AStormJust once - in adding the deps :-)07:09
AStormE.g. in gentoo depscan.sh07:10
AStormThe deps would be perfectly calculated using that.07:10
AStormand then just set in the script, like a simple list07:10
AStormWHEN_DEPS="abc def ghi" ON_DEPS="xyz zy"07:10
Keybukright07:11
Keybukbut then the job doesn't need to care about its deps, surely?07:11
Keybukif their parsed elsewhere, they can be handled elsewhere as well07:12
AStormUgh... I'd prefer to have upstart order them07:12
AStormparallelise them07:12
AStormand not do that myself :-)07:12
Keybukright07:12
Keybukbut then you end up with the situation where the job doesn't just need to know *its* deps07:12
Keybukit needs the list of deps for every one if its deps07:13
AStormYep07:13
Keybukand their deps07:13
AStormI could generate multiple job files, well07:13
AStormwith the deps pregenerated07:13
AStormbut the only catch is that I'd have to regenerate some if a "use" dependency changed. Not that bad.07:13
AStormMore clutter and puts the init code generator in the depscan.sh07:14
KeybukI can see quite easily how to convert a Gentoo init script into an Upstart job07:14
AStormYes, it's damn simple most of the time07:14
_ionWhat do you need the gentoo-start job for? Wouldn't it be enough just to start the existing rc script?07:14
Keybukbut how to make a generic job that emulates the behaviour, without that job parsing the Gentoo init script, not sure07:14
AStormJust the script07:14
AStorm_ion, for the deps07:14
AStormgentoo init script uses #!/sbin/runscript.sh07:15
Keybukthe existing rc script handles all the deps :p07:15
_ionI mean, the existing thing already handles the dependencies.07:15
Keybukit's not mad to try and replace it though07:15
AStormYes.07:15
AStormBut it's evil.07:15
Keybuke.g. we could have a sysv layer that iterated /etc/rc.d itself, etc.07:15
AStormIt's damned slow07:15
AStormKeybuk, indeed. But then, I just need to mutate rc-update :P07:15
AStormAnd add some additional event parsing, like for reload and others.07:16
AStormSo I'll just add a converter.07:16
AStormHope it turns out well... would have to detect start-stop-daemon pidfile handling, not that bad.07:16
Keybuksounds like a fun project <g>07:16
AStorm(of course, it wouldn't detect some broken scripts :P )07:16
_ionWouldn't that be a motivator for people to migrate their scripts to upstart jobs? :-) Then one nice day you notice that nobody uses the compatibility layer anymore.07:16
AStorm_ion, yep :-)07:17
_ionThe slowness, that is.07:17
AStormThe broken scripts more so07:17
AStormlike mysql one, it does a lot of weird things07:17
AStormLike checking the config on running, which should rather be done by hand07:17
AStorm_ion, I already have a crappy compat layer :P07:18
AStormWant it to become a bit better, so that I can sell upstart performance07:18
AStorm(even on Gentoo init scripts converted to upstart scripts)07:18
AStormalong with daemon autorestarting for some cases (where I can easily detect that a daemon is launched)07:19
Keybukhttp://people.ubuntu.com/~scott/cant-stop-execless-job.patch07:19
Keybuk^ that fixes the bug that means you need "exec sleep inf"07:19
AStormKeybuk, thanks :-)07:19
AStormApplying now :-)07:20
AStormThe only minus is that I have to muck with that stupid configure script07:20
AStormthat tries to install docs into PREFIX, and some other things too07:20
AStorminstead of using EPREFIX07:20
AStormBlah, the other way around07:21
AStormUgh, my badness, checked what I passed in the logs :P07:22
Keybukit does?07:22
AStormNo, it doesn't. A brain fart.07:23
Keybuk:p07:23
AStormHmm, the ChangeLog conflicted :P07:24
AStorm(expected - the patch is probably against bzr)07:24
Keybukyes07:24
AStormOk, now on to more hacking - writing that basic layer07:25
Keybukhmm07:26
Keybukinitctl stop doesn't hang for me here07:26
AStormand then to some converter07:26
AStormKeybuk, it shouldn't07:26
AStormI just supposed it would. I mean the job should be set as waiting07:26
AStormbut then stopped only on explicit stop07:26
AStormOr even maybe... just hold in the running state.07:27
AStormEven better.07:27
Keybukyou can do that07:27
AStormWill it be running?07:27
AStorm(until stopped, that is)07:27
Keybukyou've got the source in front of you?07:27
Keybuklook at doc/states.png07:27
Keybukthat's the state transition diagram07:28
Keybuknotice that pre-stop blister at the top right07:28
Keybukpre-stop is special07:28
Keybukwhen you run "stop JOB" or when an event that the job has in "stop on EVENT" is emitted ...07:28
AStormOk, nice :-)07:28
Keybuk... the job goes into pre-stop instead of stopping07:28
AStormGood.07:28
Keybukthe pre-stop script can therefore decide to delay the stop07:28
AStormThat's what I expected.07:28
Keybukor even revert it altogether07:28
AStorm(it won't delay)07:29
Keybukin "pre-stop script", if the job cannot be stopped, just run "start" :)07:29
AStormThe task is set to stopped after post-stop, right?07:29
Keybukthere's no "stopped" state07:29
Keybukif you mean when does the stopped event get emitted, that is after post-stop, yes07:29
AStormYes.07:29
AStormGood.07:29
AStormthe pre-start is ran when?07:30
AStormjust before the start itself, right?07:31
AStormwith the starting event emitted, or no? (vetoable?)07:31
AStormand the started is after post-start?07:31
AStormI'm reading the graph right?07:31
Keybukstarting is emitted07:32
Keybukthen pre-start is run07:32
Keybukthen the "exec"/"script" process (if any) is spawned07:32
Keybukthen post-start is run07:32
Keybukthen started is emitted07:32
Keybuk-- 07:32
Keybukpre-stop is run07:32
Keybukthen stopping is emitted07:32
Keybukthen the "exec"/"script" process (if any) is killed07:32
Keybukthen post-stop is run07:33
Keybukthen stopped is emitted07:33
AStormWhat about when pre-start vetoes?07:33
Keybuk-- 07:33
AStormIs the stopping emitted?07:33
Keybukif pre-start runs "stop", then you get stopping and stopped emitted07:33
AStormHmm...07:33
Keybuk(red line out of pre-start)07:33
AStormBad for my health :P07:33
AStormI'd just like to veto a start07:33
AStormGo back to waiting then deleted maybe...07:33
AStormSome way.07:34
AStormSo that whichever got started due to starting event, is there07:34
Keybuktbh, I can't remember why starting/pre-start are that way round, but pre-stop/stopping are the other way around07:34
AStorm(even if it's listening on stopped)07:34
Keybukyou can do that in an odd way07:35
AStormAh right.07:35
AStorma fail event07:35
Keybukif you have something that does "start on starting"07:35
AStormThis won't call the stopping, right?07:35
Keybukthen it can look at $1, and call "stop $1" :)07:35
AStormHmm.07:35
Keybuk(the theory is that pre-start's "opposite job" is post-stop)07:36
AStormBecause those Gentoo scripts are pesky and I want to emulate the whole behaviour07:36
Keybukso if you run pre-start, you always need to run post-stop07:36
Keybukand because post-stop is run, you'd get a stopped event07:36
Keybukso you need some kind of starting event first07:36
AStormthe brokenness is that the deps aren't stopped when the task fails to start07:36
AStorm(e.g. due to checkconfig)07:36
Keybukand since you have a starting event, you also need a stopping event, since some things might run between those two things07:37
AStormAnd I'd have to do that in the script itself then :P07:37
Keybukthat's possible in upstart07:37
AStormAnd can't dep on started :/07:37
Keybukgentoo-start/failed07:37
AStormHmm.07:37
AStormI know.07:37
Keybukthat event will be emitted if the job it tried to start failed to start07:37
AStormThey'd have to depend on both the usual and the failed :P07:37
AStormBrokenness emulated bug for bug.07:37
AStormThe slash is required, or can I write on started gentoo-start failed?07:38
AStormor even * there?07:38
Keybukslash is required07:38
Keybuksince it's a different event07:38
AStormAh, ok.07:38
AStormNot a problem.07:38
Keybukyou could also do something like; exit 1 from pre-start to fail the job07:39
Keybukthen you get a "gentoo-job stopping failed pre-start" event :p07:39
AStormBut that wouldn't launch the deps.07:39
AStormI want to emulate bug for bug :P07:39
AStormI think I'll go with the "multiple files" approach.07:40
AStormcode duplication all right, but will look more like handwritten code07:41
AStormthe runscript would still have to be modified anyway, to disable its own dep resolution07:41
Keybukright07:41
Keybukdinner07:41
Keybukbbl07:42
Keybukenjoy07:42
AStormOr is there a way to bypass #! line?07:42
Keybuksure sh -escript07:42
AStormGreat.07:42
AStormHmm, even the "when" would be too far07:45
AStormJust on07:45
AStormstop on stopping ourdep07:46
AStormBecause that's broken in Gentoo init scripts too :P07:46
AStormBlah, even better07:48
AStormI just need to source the given init script07:48
AStormthen call its "start" function07:48
AStormthe more problematic would be reload which some scripts have07:48
AStormWhich doesn't necessarily just restart the app.07:48
AStormThough that could be just an another handler, e.g. on some parameter07:49
AStormSo you could do: initctl emit xyzzy reload07:49
AStormor initctl emit xyzzy stop07:49
AStormOr better, initctl stop xyzzy07:49
AStormSimple then.07:50
AStormJust read OPTS variable.07:50
AStorm(gets sourced in)07:51
AStormthe reload is the default one07:51
AStormIf not present, it's just start/stop, will have to emulate that somehow.07:51
AStormProbably by defining our own bash function, then sourcing. This will override our own definition.07:59
AStormWouldn't it be nice to have the reload event separated from restarting, generally?08:02
AStormE.g. special events "reloading xyzzy" "reloaded xyzzy"08:03
AStormBut then... the reload xyz would just emit these simply and call pre-reload08:04
AStormreload08:04
AStormand post-reload08:04
AStormActually, just launch a reload event with reloading and reloaded. No need for special syntax :>08:04
_ionThat could be useful. Let's ask Keybuk's thoughts about it when he returns.08:05
AStormOf course, the states would only be emitted if the event had reload in it.08:10
AStormand add the initctl function reload08:12
AStormit'd fail if the event wouldn't support it08:12
AStorms/wouldn't/didn't/08:13
AStormcould just fall back to stop/start08:15
AStormor just start if not running08:16
AStormTemporarily, I'll just create more events08:30
AStormActually, I'll use a parameter.08:31
AStormThese become just $1, $2 etc?08:31
AStormI'm wondering... how to avoid checking filesystems from the same drive in parallel08:56
AStormHmm.08:56
AStormMaybe just something simple... I'd do away with the fstab anyway - it'd be parsed.08:57
AStormWell, the simplest would be to just sort based on the drive ID, using standard Unix device names... but that'd break with LVM and some Udev manglings09:00
AStormLVM can be worked around by parsing lvs09:01
AStormBut don't know about udev...09:01
_ionThe Ubuntu people might have a solution for that problem. They've surely had to think about it, as they're going to implement that for the next release.09:03
_ionBetter ask Keybuk.09:04
AStormHmm... or maybe not :P09:04
AStormMaybe they just punted at the problem - the scanning will just get slower09:04
AlexExtremeKeybuk said he would release an upstart-based init sequence for ubuntu today or tomorrow, we should wait to see what's been done there09:04
AStormGreat, just great. I shall see.09:05
=== Md [i=md@freenode/staff/md] has joined #upstart
AStormUh, yes, md would be problematic too (no, not you)09:05
AlexExtreme:P09:05
AStormRAID and stuff - you don't know which is on which physical disc.09:05
AStormWould need physical FS data.09:06
AStormHmm... there is an option...09:06
AStormparsing /proc/diskstats09:06
AStormJust do a simple read on each of the partitions09:07
AStormand see which disk's stats got upped09:07
AStormBut that'd have to be done in single mode.09:07
AStormIf one could get a hardware Udev id...09:09
AStormBut then, that doesn't tell us anything about LVM or RAID. Though these can be worked around.09:09
arachnistwasn't upstart supposed to be crossplatform? i'm quite sure that /proc/diskstats is nonexistant on bsd's, even with linprocfs mounted on /proc09:10
AlexExtremewell09:10
AlexExtremethis would be in the job files09:10
AlexExtremewhich are distro specific09:11
AStorm:>09:11
arachnistoh, ok09:11
AStormOk.09:12
AStormudevinfo returns the hardware ID.09:12
AStormOne problem less. Now I'll check the LVM.09:12
AStormHmm, udevinfo is useless against LVM or RAID.09:17
AStormBut these fortunately have their own tools. RAID has mdstatus09:17
AStormLVM has lvs09:17
=== theCore [n=alex@ubuntu/member/theCore] has joined #upstart
AStormThe parsing would be done by a special util, so as not to slow down the startup. Will write such a script now.09:18
AStormlvs+pvs for LVM (converting to physical device), udevinfo for physical volumes09:21
AStormDon't remember md, so it'll have to wait.09:21
MdI think you are looking for /lib/udev/vol_id09:22
_ionUbuntu added /lib/udev/watershed to the udev packaging recently, it should be helpful when multiple fscks are supposed to be run.09:23
_ion(i think)09:23
AStormMd, that's one thing.09:23
AStormNo, udevinfo will be enough.09:24
AStormvol_id requires the device path, so it's useless.09:24
AlexExtreme_ion, what does that do?09:24
AStormKnowing the device path means I know everything.09:24
AStormFor knowing the LVM volumes, one just needs to run vgscan - and that's needed anyway09:25
AStormvgscan, then parse lvs and pvs info09:26
AStormthen we get the device name.09:26
AStormWhich can be probed using udevinfo --name=device --query=env09:26
AStormto get the unique hardware id09:26
_ionalexextreme: If you run /lib/udev/watershed sleep 2 twice, the other one won't be started until the first one has finished.09:27
AlexExtremeah09:27
AStormEven better :>09:27
AStormOne can just do some ls on sysfs09:28
AStormto get where the device mappings are stored09:28
AStormI'll see the libsysfs09:28
AStormYes, there is a tool in sysfsutils09:30
AStormsystool09:30
AStormBut why depend on an external tool, when few ls or finds will suffice?09:32
AStorm*a few09:32
AStormThe basic partitions are just subdirs of the drive subdirectory09:33
AStormthe device mappings are on their own, but they have the parition(s) they're contained in symlinked in slaves subdir09:34
AStormAlso, the partitions/discs have the symlink to the mappings in holders09:35
AStormsubdirectory09:35
AStormSimple enough to write a script to detect that in realtime.09:36
AStormOnly swap partitions will have to be ignored...09:38
AStorm(/proc/swaps)09:39
AStormBah, can't use /proc/swaps.09:39
AStormThe entry won't be there yet, the swap isn't enabled.09:39
_ionYay, i booted my computer using upstart 0.3.5 + my watch_delayed patch. It works.09:40
AStormThe simplest would be to create fsck.swap, which does nothing.09:40
AStormHow does one detect that a partition is swap in Linux? :>09:43
AStormw/o trying to mount it09:43
AStormAh, right.09:45
AStormmount -f -v09:45
AStormBlah, that does print unknown only09:46
AStormAny ideas?09:46
=== arachnis1 [i=arachnis@088156186027.who.vectranet.pl] has joined #upstart
=== arachnis1 is now known as arachnist
phsdvyou do not want to look in /etc/fstab? I mean there could be swap partitions that I do not want to use10:00
AlexExtremehmm10:01
AlexExtremejust installed herd 2 in vmware from an iso i downloaded a while back10:01
AlexExtreme"only" 409 updates :p10:01
AlexExtremenight10:03
=== arachnis1 [i=arachnis@088156186027.who.vectranet.pl] has joined #upstart
phsdvnight10:04
=== phsdv [n=paul@dyn-83-152-239-92.ppp.tiscali.fr] has left #upstart ["Time]
=== AstralSt [n=astralst@host-81-190-179-124.gorzow.mm.pl] has joined #upstart
=== AstralSt is now known as ASotrm
=== ASotrm is now known as AstralSt
=== AstralSt is now known as AStorm
AStormBlah, it's just a syscall, that swapon.10:21
AStormHeh, the first page of swap contains a magic ID10:35
AStormSWAP SPACE for old swap10:36
AStormSWAPSPACE2 for newer one10:36
AStormSWAP-SPACE for old10:36
AStormold is unsupported in 2.6 AFAIK anyway, so we don't have to bother.10:36
AStormThe only thing I have to know is current page size.10:36
AStormNow, the idea is - can I get the pagesize w/o launching any C code? :P10:39
AStorm(that and some head+tail would be enough for basic detection)10:39
=== AStorm [n=astralst@host-81-190-179-124.gorzow.mm.pl] has joined #upstart
AStormIn case of problems, I'll just punt and check the largest pagesize10:51
AStormAh, it should be in the libc headers.10:54
AStormOk, it's in Linux :P11:00
AStormThe largest number of bytes is 1 << 2211:00
AStormThat's some kind of sparc6411:00
AStormUsually it's 1 << 12 or 409611:00
AStorm1 << 22 is... 4MB!11:01
AStormNow that's some page :>11:01
AStormI'd like to avoid grepping 4 MB of the swapfile, but oh well :P11:04
AStormhead -n 4m | grep -U SWAPSPACE2 is ok... but..11:16
AStormI think that trying to swapon would be faster than that...11:17
AStormthough the simple check would be faster if I could somehow get the page size11:17
AStormor write a tiny C prog "isswap"11:17
_ionKeybuk's dinner has taken a while. :-)11:48
AStormRight.11:51
AStormAnd I've finished that swap detector11:51
AStormas a bonus, it detects old v1 swap space as non-swap11:51
AStormso will bork :-)11:51
AStormA special return code of 211:51
AStorm1 if not swap space11:51
AStorm0 if swap space v211:51
AStorm254 for file open error11:52
AStorm255 for argument error11:52
AStormNo usage (quite obvious - give it a device name)11:52
AStormUses mmap for extra speed :P11:53
_ionIn case anyone's interested, this is the upstart patch i've been using for a while, it seems to do the right thing. http://soijabanaani.net/tmp/upstart_watch_delayed.diff11:53
_ionIt compiles with the libnih from https://code.launchpad.net/~ion/+branch/libnih/watch-delayed11:54

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