[02:21] <_ion> Does anyone know which tool Keybuk uses for keeping the ChangeLog file updated in bzr? === theCore [n=alex@ubuntu/member/theCore] has joined #upstart === j_ack [n=rudi@p508D8BB1.dip0.t-ipconnect.de] has joined #upstart [04:26] <_ion> Phew. 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.diff [04:26] <_ion> Writing that took like ten times the time it would have taken if i could concentrate normally. [04:27] <_ion> Here's also a small parenthesis fix, http://soijabanaani.net/tmp/nih_hash_foreach_parenthesis.diff === 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 [11:30] int0x0c, are you trying to get upstart going on gentoo? === juergbi [n=juerg@80-219-17-102.dclient.hispeed.ch] has joined #upstart [11:45] I just uploaded an ebuild for 0.3.5 into gentoo bugzilla (http://bugs.gentoo.org/show_bug.cgi?id=150190) === 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 [03:09] so, I came up with a neat idea ... [03:09] you know how we have emits ? [03:09] that'd be a really nice way of defining special events [03:10] job lists the event names with the emits stanza [03:10] and when started, sends a message to upstart saying that it wants active notification of registrations [03:10] upstart sees it's from a pid of a known job, that has listed emits stanzas [03:10] so sends the job back as a reply every use of "on THAT-EVENT" [03:10] and whenever new jobs are registered, or jobs are deleted, keeps that process up to date [03:11] e.g. [03:11] a job called "inetd" [03:11] emits tcp udp [03:11] connects to upstart [03:11] and receives information that there are jobs with [03:11] on tcp 80 [03:11] on udp 53 [03:11] etc. [03:11] so it knows to listen on those ports, and knows to emit events with those arguments [03:12] sounds good [03:14] so, there's most of the work for replacing inetd done? :P [03:16] it means you can take exotic events out of the core [03:16] don't want inetd support? don't run upstart-ientd [03:16] yes [03:17] useful for the dbus proxy too [03:17] on dbus com/redhat/dhcp/eth0 com.redhat.dhcp.down [03:17] so it'd know to listen to that signal, and emit that evnet === j_ack [n=rudi@p508D92A9.dip0.t-ipconnect.de] has joined #upstart [04:06] <_ion> keybuk: Ooo, really nice idea. [04:06] <_ion> keybuk: Any comments about the watch_delayed thing? [04:07] I looked at the code, and it looked pretty good [04:07] haven't had a chance to test it yet; want to get complex-event done today since we want that asap [04:07] <_ion> All right. [04:08] will look at it properly this week : ) [04:09] <_ion> You might want to include nih_hash_foreach_parenthesis.diff immediately though, it fixes a bug. :-) [04:10] yeah, I saw that [04:10] thanks! [04:10] can you paste me a changelog for that one [04:12] <_ion> * nih/hash.c (NIH_HASH_FOREACH, NIH_HASH_FOREACH_SAFE): Added missing parenthesis. [04:12] <_ion> Is that enough? :-) [04:13] <_ion> Duh, nih/hash.h, not .c [04:13] <_ion> What tool do you use to maintain the changelog and have it integrated with bzr commits, btw? [04:13] <_ion> A bzr plugin? [04:14] a shell script [04:15] <_ion> Is it available for downloading? :-) [04:15] http://people.ubuntu.com/~scott/software/bzr-commit [04:15] <_ion> Thanks [04:15] I maintain the ChangeLog first using emacs (C-x 4 a) [04:16] and then just use that to do the commits, with the changelog diff [04:16] actually -- can you commit your watch delayed stuffa [04:16] and push it to a branch of your own? [04:18] something like [04:18] <_ion> Actually 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:19] bzr push sftp://ion@bazaar.launchpad.net/~ion/libnih/watch-delayed [04:19] I think is the format [04:19] that should automatically register it on https://code.launchpad.net/libnih === mbiebl [n=michael@e180118213.adsl.alicedsl.de] has joined #upstart [04:52] <_ion> keybuk: https://code.launchpad.net/~ion/+branch/libnih/watch-delayed [04:54] excellent [04:54] wing-commander scott% ./parse "foo bar baz until frodo bilbo and eep" [04:54] Operator (AND) [04:54] Event ("eep") [04:54] Operator (UNTIL) [04:54] Event ("frodo", "bilbo") [04:54] Event ("foo", "bar", "baz") [04:54] \o/ [04:54] now to figure out whether I've got the precedence right :p [04:54] <_ion> \o/ [04:55] wing-commander scott% ./parse "foo until bar and frodo until bilbo" [04:55] Operator (AND) [04:55] Operator (UNTIL) [04:55] Event ("bilbo") [04:55] Event ("frodo") [04:55] Operator (UNTIL) [04:55] Event ("bar") [04:55] Event ("foo") [05:10] <_ion> keybuk: 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:11] <_ion> The actual delayed watch code is in revno 387. [05:12] wing-commander scott% ./parse "set timer until (boom or kaboom)" [05:12] Operator (UNTIL) [05:12] Event ("set", "timer") [05:12] Operator (OR) [05:12] Event ("boom") [05:12] Event ("kaboom") [05:12] \o/ [05:13] <_ion> \/ [05:13] :) [05:13] <_ion> keybuk: Have you decided a name for the complex-event-spec stanza yet? :-) [05:14] wing-commander scott% ./parse "fhs-filesystem-mounted until fhs-filesystem-down and network-up until network-down" [05:14] Operator (AND) [05:14] Operator (UNTIL) [05:14] Event ("fhs-filesystem-mounted") [05:14] Event ("fhs-filesystem-down") [05:14] Operator (UNTIL) [05:14] Event ("network-up") [05:14] Event ("network-down") [05:14] _ion: nope [05:22] wing-commander scott% ./parse "with apache or with thttpd" [05:22] Operator (OR) [05:22] Operator (WITH) [05:22] Event ("apache") [05:22] Operator (WITH) [05:22] Event ("thttpd") [05:22] yay [05:22] even unary works [05:22] <_ion> Whee [05:23] <_ion> D'oh, i wrote "patch change events" to the changelog entry. :-) [05:24] oops [05:26] ok, I think the parser works [05:27] got to make config respect parens as newline escapers, then try and recodify my ugly quick C into a stanza parser [05:49] interesting question [05:49] should this: [05:49] FOO blah and (blah until blah # some comment [05:49] or blah until blah) [05:49] be valid [05:49] (ie. comment inside parens [05:50] <_ion> I don't see why not. Someone might want to do something like this, while testing something: [05:50] it's kinda unique in the format, since nothing else uses parens [05:50] <_ion> FOO something something (something # comment out the rest of the line, something something [05:51] <_ion> # comment out also this part, something something) [05:51] <_ion> new stuff) [05:51] and I do think not being required to escape newlines inside parens is useful === AStorm [n=astralst@host-81-190-179-124.gorzow.mm.pl] has joined #upstart [06:06] Hello. === arachnist [i=arachnis@paludis/monkey/arachnist] has joined #upstart [06:06] hey AStorm [06:06] _ion: merged 386 [06:07] I've ran upstart on Gentoo, basic compatibility right now [06:07] (running large /sbin/rc, and requires a small modification of one script) [06:07] sweet, do you have the details of what needs to be done? [06:07] I'm developing a fully event-based init system for it. [06:07] planning to ship some example jobs in the upstart tarball directly with the next version, would be cool to have a gentoo subdir in there [06:07] And I've some questions, esp. regarding mounting [06:07] sure [06:08] Is there something like stop for these? [06:08] Like the default plain exec is start [06:08] then stop would be ran on stopping. [06:08] sorry, not sure I understand [06:08] Or do I have to use post-stop? [06:08] You know, I don't want to split the event in two. [06:09] oh, I see what you mean [06:09] upstart's jobs aren't quite analogous to init scripts [06:09] (could do this with unmount-dev script for "on stopped mount-dev") [06:09] I'd rather have it called directly in one script. [06:09] you can do it one of two ways [06:09] Can do this in post-stop right now... [06:09] have two jobs, mount and unmount [06:09] (or in pre-stop) [06:09] one that mounts things, one that unmounts them [06:09] But it feels unclean. [06:09] and have them otherwise unrelated [06:10] or [06:10] you can have them in one job [06:10] related related [06:10] if you have them in one job, put the mount stuff in pre-start [06:10] and the unmount stuff in post-stop [06:10] By the unmount one would dep "on stopped mount-dev" [06:10] and don't have an exec or a script [06:10] the job would appear to be "running" all the time the disk is mounted [06:10] Exactly. [06:10] (note that there's a sliiight bug there atm) [06:11] Bug? What kind of? [06:11] it won't ever actually stop [06:11] hmm. [06:11] it slipped in at the last minute yesterday before I released 0.3.5 [06:11] Right, because it's no daemon and there's no SIGCHLD, right? [06:11] I didn't have a good enough test case for it [06:11] Funny bug. So, for now, I'll split the script. [06:12] right; because when the stop event comes in, it will only change the goal to stop -- and won't force a state change [06:12] Funny. [06:12] this worked a few days ago [06:12] Not a problem with me, but with the users... [06:13] Now to unmount the device, they'd have to "start" the unmount [06:13] not stop the mount :-) A bit illogical. [06:13] would you have one job per mounted disk, or one job for all of fstab ? [06:13] Rather the first one [06:13] right [06:13] But the job would work using an argument. [06:14] for the first one, you'd do something like: [06:14] instance [06:14] start on block-device-added [06:14] stop on block-device-removed [06:14] or something [06:14] Yes, something like that probably. [06:14] the instance bit is important, it tells upstart that multiple copies can be running [06:14] But right now, it's /dev mounting, which is doubly funny [06:14] (temporary fix [06:14] rather than splitting into two jobs, just have a dummy script [06:14] Aha, nice, undocumented. [06:15] pre-start script [06:15] # mount stuff [06:15] end script [06:15] Fine, very fine. [06:15] post-stop script [06:15] # unmount stuff [06:15] end script [06:15] I know. the bug is just when I exec something, right? [06:15] (in full start) [06:15] script [06:15] while true; do sleep 1000; done [06:15] end script [06:16] <_ion> sleep inf [06:16] the script...end script will mean that there's a process running while the disk is mounted [06:16] _ion: does that work? :p neat [06:16] exec sleep inf [06:16] :p [06:17] <_ion> It works with GNU sleep, but not with e.g. the BSD one. [06:17] Keybuk, uh, a bit evil hack, but temporarily I'll do that. [06:17] then this week, when I fix that bug, you can drop the sleep :p [06:17] _ion, not a problem here, it's Gentoo and it's temporary. [06:18] Good, very good. [06:18] the 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-effect [06:18] The major thing will be forcing udev to generate events [06:18] the default rules don't do that [06:18] this turns out to be wrong, simply because the child reaper actually does want to force a state change as a side-effect :p [06:18] so all I need to is fix the child reaper, and remove the bogus check from job_change_goal [06:18] need to write some test cases for it first though [06:19] Just check the state [06:19] after running some echo in pre-start [06:19] and something else in post-stop [06:19] (e.g. some file write), then check if the file was written [06:19] Without any exec inside. [06:20] I wonder if initctl stop thatservice would hang [06:21] sorry? [06:21] The state would change properly to stopping? [06:21] Is it just that the task doesn't enter "waiting" state? [06:22] or something else totally? [06:23] Or just that it finishes too early? [06:24] post-stop gets run in stopping [06:24] and then it should go to waiting [06:25] initctl hangs is probably the bug [06:27] Hmm, the test would be quite hard. [06:27] Because of the hang, you'd have to use shell job control with some timeout. [06:29] damned halting problem, eh? :P [06:34] AStorm, 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 know [06:35] Well, the help would be wrt making udev send upstart events [06:36] that's easy [06:36] I've overwritten my init with upstart currently, have the stupid way of compatibility (running full gentoo init) working [06:36] AlexExtreme, so then, describe it to me, I'd be grateful. [06:36] AStorm: RUN+="initctl emit some-event" [06:37] ACTION=="add", SUBSYSTEM=="block", KERNEL=="*[!0-9] ", RUN="/usr/sbin/initctl emit block-device-added %k" [06:37] I'm not a master of init rules... [06:37] damn [06:37] beat me to it :) [06:37] phsdv, ok, so simple :-) [06:37] So I'll have to also do a package of udev rules - expected that. [06:37] I had them ready... wrote them a while ago [06:37] phsdv: add "-eDEVNAME" to that [06:37] -eDEVNAME? [06:37] phsdv, could you mail them to me then? (or put somewhere I can get them) [06:38] The parameter, you know [06:38] or environment variable DEVNAME [06:38] phsdv: put the DEVNAME environment variable in the environment of any job run by the block-device-added event [06:38] <_ion> -eBAR without =quux grabs the value from the current environment? Nice. [06:38] Great. It's so bad the upstart is so undocumented yet :-) [06:38] ACTION=="remove", SUBSYSTEM=="block", KERNEL=="*[!0-9] ", RUN="/usr/sbin/initctl emit block-device-removed %k" [06:39] ^ same for remove [06:39] phsdv, I know, I know. [06:39] AStorm: heh, I do have "document it" high on the TODO list [06:39] though remember, a lot of the features you're using today were only written in the last week === j_ack_ [n=rudi@p508DB9F4.dip0.t-ipconnect.de] has joined #upstart [06:39] Keybuk, hehe, I'll do something like that [06:39] when I finish full gentoo init script compat [06:39] which will consist of modified depscan.sh and runscript.sh [06:40] (to store the dependencies in upstart scripts) [06:40] Maybe also some mapping, like: net="network-device-eth0:network-device-eth1" [06:42] The hardest part will be deps of type "use" [06:42] The script would have to check the list of added services (simple, right :P ) [06:43] Keybuk, is it possible to parametrise the dependencies, so I don't have to generate scripts? [06:43] As in the dependency would be a parameter, some environment value? [06:43] <_ion> Well, you could do as Ubuntu does: keep the old compatibility layer there and gradually rewrite things from the old system to upstart. [06:44] I'm just thinking about that. [06:44] Just moving the most basic layer to upstart now [06:44] and write the compat script [06:45] Keybuk, so, is that possible? To base "dependencies" (events I want get started on) on the environment variable or a parameter? [06:45] AStorm: What about documenting your work on the wiki? [06:45] http://upstart.ubuntu.com/wiki/UpstartOnGentoo [06:45] I'll do that :-) [06:45] When I have something working, I'll do an ebuild and document it. [06:46] Great, seems as many gentooers are already playing with upstart and there is much duplicated effort. [06:46] Not a lot, though. [06:47] Upstart is so nice, the amount of "work" required is low. [06:47] (except that possible conversion script - that requires a tiny bit of bash-fu) [06:48] AStorm: I'm not sure I understand what you mean? [06:48] Keybuk, like that: [06:48] There is an event send, let's call it run-me [06:49] It is emitted with an unknown number of parameters: abc def ghi [06:49] And I want to have them converted to: on abc and on def and on ghi [06:50] Maybe a tiny extension of the syntax - explicit and? [06:50] and support for environment vars in calculation of the events/ [06:51] so you have [06:51] E.g. I could do: initctl run-it DEPS="abc def ghi" [06:51] "run-me abc def ghi" [06:51] and do: on $DEPS [06:51] ? [06:51] I don't have that yet :-) [06:51] I'm still trying to understand what you're trying to do, I'm afraid [06:51] s/initctl/initctl emit/ === Keybuk has never seen the Gentoo init system [06:52] it's *very* complicated :) [06:52] Keybuk, it's a simple "need" based system [06:52] AlexExtreme, not really [06:52] With some "after and before" [06:52] so when a job starts, it causes the jobs it needs to also be started? [06:52] it seemed that way to me :P [06:52] Keybuk, exactly. [06:52] or is it the kind where a job is not started until everything it needs has been started by something else? [06:52] Like that old "depend" trick [06:53] Which was obsoleted some time ago [06:53] Keybuk, the second one rather [06:53] in upstart, if "FOO" needs "BAR" then in FOO's job file, you would write: [06:53] start on started FOO [06:53] stop on stopping FOO [06:53] Exactly. [06:53] err [06:53] s/FOO/BAR/ in that :p [06:53] And I'd add in the main one: start on gentoo [06:54] and stop on gentoo [06:54] that one would emit proper events to run things [06:54] in the main one? [06:55] Something like that, right. [06:55] main what? [06:55] A conversion of Gentoo init to rcS, so it seems. [06:55] It's just that the script "gentoo" would call the wrapper for gentoo-style init multiple times [06:55] maybe I need to rewind here [06:55] are you wanting to know how to rewrite current init scripts into upstart native jobs ... [06:56] and this wrapper would get the deps right (precalculated by script) [06:56] ... or are you trying to find out how to write a generic job that can start any gentoo init script ? [06:56] Keybuk, the last one [06:56] aha! [06:56] right, basis of my confusion here then :p; [06:56] This would simulate gentoo runlevels. [06:57] and the smaller script would just launch things [06:57] well, at the most basic level, you need a job that handles the simple case of starting, running and stopping one job [06:57] Exactly, but with parametrised deps [06:57] ideally, that would need to spawn the job in the pre-start script, and then kill it again in the post-start script [06:57] But then, I'd need a wildcard [06:57] and somehow wedge in the running state while the job is actually running [06:58] Yes. [06:58] first you need to write the job, without any deps [06:58] you could do it all in "script" in fact [06:58] script [06:58] /etc/init.d/$JOB start [06:58] Exactly [06:58] That's what I want... [06:58] while [ -f /var/run/$JOB.pid ] ; do sleep 1; done [06:58] but for deps I'd need to match on the JOB variable [06:58] /etc/init.d/$JOB stop [06:58] end script [06:58] No pidfile support [06:58] though that's not quite right, since stopping the upstart job would not stop the gentoo one [06:59] what I might do there is [06:59] Gentoo is using the pids itself in the scripts [06:59] post-start script [06:59] /etc/init.d/$JOB start [06:59] end script [06:59] script [06:59] Just call /etc/init.d/$JOB stop [06:59] Yes, that's it. [06:59] while /etc/init.d/$JOB is-running; do sleep 1; done [06:59] end script [06:59] pre-stop script [06:59] /etc/init.d/$JOB stop [06:59] end script [06:59] "is-running" is impossible yet. Just sleep instead :P [06:59] right, but how do you know if someone stops the job when you weren't looking? :p [07:00] if you don't care, then omit the "script ... end script" bit [07:00] Well... [07:00] (and replace with exec sleep inf until I fix this bug) [07:00] Exactly, don't care. [07:00] ok [07:00] Stupidity is not rewarded :P [07:00] so this gives you a job that will start and stop any gentoo job when it, itself, is started and stopped [07:00] And init scripts are disallowed to call stop on others explicitly [07:00] (Gentoo policy) [07:00] of course, you need to mark this "instance" because you want multiple copies running [07:00] Yes. [07:00] But I need a match on $JOB [07:01] now, you'll want an event to start up an instance for a given job [07:01] and another event to stop an instance for the same job [07:01] easiest way to define that [07:01] to start its deps earlier [07:01] initctl emit gentoo-start -eGENTOO_JOB=NAMEOFJOB [07:01] initctl emit gentoo-stop -eGENTOO_JOB=NAMEOFJOB [07:01] Yes. [07:01] so stick in the gentoo job file [07:01] start on gentoo-start [07:01] stop on gentoo-stop [07:01] But then, the deps are to be given as the parameters still [07:01] (because of the need system) [07:01] and use $GENTOO_JOB throughout [07:01] or the single script won't work [07:01] (getting to dependencies) [07:02] Can I do a match like: [07:02] on gentoo-start GENTOO_JOB=xyz * [07:02] no [07:02] or would the DEPS variable be ignored? [07:02] (if I don't match on it) [07:02] question [07:02] how would you like deps to be handled? [07:03] if you start FOO, should it cause its deps to be started? [07:03] Yes. [07:03] right [07:03] and then foo itself. [07:03] so now we improve the "gentoo-start" event [07:03] Yep. [07:03] initctl emit gentoo-stop -eGENTOO_JOB=NAMEOFJOB -eGENTOO_DEPS="dep1 dep2 dep3 dep4" [07:03] uh [07:03] s/-stop/-start/ :p [07:03] Not a problem. [07:03] now that instance, when it gets started, has $GENTOO_JOB which is the job we actually want to run [07:04] (used in post-start and pre-stop) [07:04] I'd love to avoid parsing the GENTOO_DEPS though. there's no way yet, right? [07:04] (like just putting on started $GENTOO_DEPS) [07:04] Or rather: [07:04] when $GENTOO_DEPS [07:04] and that instance also has $GENTOO_DEPS [07:04] so the simplest way is to add [07:04] pre-start script [07:04] which would expand to when dep1 and when dep2 and when dep3 [07:04] for DEP in $GENTOO_DEPS; initctl emit gentoo-start $DEP; done [07:04] end script [07:05] that wouldn't do what you want [07:05] that would emulate the second kind of system [07:05] It would do it too :-) [07:05] Ah, right. [07:05] the need would add when [07:05] the use would add on [07:05] :-) [07:05] that's the catch [07:05] Or even better. [07:05] use would still add when [07:05] after would add on [07:05] err? [07:06] before would work like after, but backwards [07:06] Gentoo has 4 kinds of deps: [07:06] nope, completely lost me [07:06] need, use, before and after [07:06] need means a hard dependency [07:06] need implies that if you try and start $JOB, then its dependencies come up first [07:06] so we should get restarted when the dependency is [07:06] ? [07:06] Yes [07:07] But also when you restart that dependency, the package itself is restarted too. Like when [07:07] use 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 then [07:07] ok [07:08] after and before are for ordering, doable using on. [07:08] random thought; I wouldn't pass $UPSTART_DEPS as part of the evnet [07:08] s/UPSTART/GENTOO/ [07:08] in the pre-start script, I'd parse the gentoo init script to get them [07:08] Hmm... [07:08] that way you don't need to duplicate code everywhere [07:08] And add the aliases there too? [07:08] right [07:08] Would be very fat. [07:08] Bad idea. [07:09] I can precalculate them. [07:09] yeah, but you have a single job then which handles the entire case of starting and stopping a gentoo init script [07:09] and just needs the name [07:09] rather than trying to duplicate the code everywhere [07:09] Yes. [07:09] you'd need the "extract list of deps" code in several places, otherwise [07:09] But parsing is slow. [07:09] I want to avoid this slowness by parsing once. [07:09] Just once - in adding the deps :-) [07:10] E.g. in gentoo depscan.sh [07:10] The deps would be perfectly calculated using that. [07:10] and then just set in the script, like a simple list [07:10] WHEN_DEPS="abc def ghi" ON_DEPS="xyz zy" [07:11] right [07:11] but then the job doesn't need to care about its deps, surely? [07:12] if their parsed elsewhere, they can be handled elsewhere as well [07:12] Ugh... I'd prefer to have upstart order them [07:12] parallelise them [07:12] and not do that myself :-) [07:12] right [07:12] but then you end up with the situation where the job doesn't just need to know *its* deps [07:13] it needs the list of deps for every one if its deps [07:13] Yep [07:13] and their deps [07:13] I could generate multiple job files, well [07:13] with the deps pregenerated [07:13] but the only catch is that I'd have to regenerate some if a "use" dependency changed. Not that bad. [07:14] More clutter and puts the init code generator in the depscan.sh [07:14] I can see quite easily how to convert a Gentoo init script into an Upstart job [07:14] Yes, it's damn simple most of the time [07:14] <_ion> What do you need the gentoo-start job for? Wouldn't it be enough just to start the existing rc script? [07:14] but how to make a generic job that emulates the behaviour, without that job parsing the Gentoo init script, not sure [07:14] Just the script [07:14] _ion, for the deps [07:15] gentoo init script uses #!/sbin/runscript.sh [07:15] the existing rc script handles all the deps :p [07:15] <_ion> I mean, the existing thing already handles the dependencies. [07:15] it's not mad to try and replace it though [07:15] Yes. [07:15] But it's evil. [07:15] e.g. we could have a sysv layer that iterated /etc/rc.d itself, etc. [07:15] It's damned slow [07:15] Keybuk, indeed. But then, I just need to mutate rc-update :P [07:16] And add some additional event parsing, like for reload and others. [07:16] So I'll just add a converter. [07:16] Hope it turns out well... would have to detect start-stop-daemon pidfile handling, not that bad. [07:16] sounds like a fun project [07:16] (of course, it wouldn't detect some broken scripts :P ) [07:16] <_ion> Wouldn'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:17] _ion, yep :-) [07:17] <_ion> The slowness, that is. [07:17] The broken scripts more so [07:17] like mysql one, it does a lot of weird things [07:17] Like checking the config on running, which should rather be done by hand [07:18] _ion, I already have a crappy compat layer :P [07:18] Want it to become a bit better, so that I can sell upstart performance [07:18] (even on Gentoo init scripts converted to upstart scripts) [07:19] along with daemon autorestarting for some cases (where I can easily detect that a daemon is launched) [07:19] http://people.ubuntu.com/~scott/cant-stop-execless-job.patch [07:19] ^ that fixes the bug that means you need "exec sleep inf" [07:19] Keybuk, thanks :-) [07:20] Applying now :-) [07:20] The only minus is that I have to muck with that stupid configure script [07:20] that tries to install docs into PREFIX, and some other things too [07:20] instead of using EPREFIX [07:21] Blah, the other way around [07:22] Ugh, my badness, checked what I passed in the logs :P [07:22] it does? [07:23] No, it doesn't. A brain fart. [07:23] :p [07:24] Hmm, the ChangeLog conflicted :P [07:24] (expected - the patch is probably against bzr) [07:24] yes [07:25] Ok, now on to more hacking - writing that basic layer [07:26] hmm [07:26] initctl stop doesn't hang for me here [07:26] and then to some converter [07:26] Keybuk, it shouldn't [07:26] I just supposed it would. I mean the job should be set as waiting [07:26] but then stopped only on explicit stop [07:27] Or even maybe... just hold in the running state. [07:27] Even better. [07:27] you can do that [07:27] Will it be running? [07:27] (until stopped, that is) [07:27] you've got the source in front of you? [07:27] look at doc/states.png [07:28] that's the state transition diagram [07:28] notice that pre-stop blister at the top right [07:28] pre-stop is special [07:28] when you run "stop JOB" or when an event that the job has in "stop on EVENT" is emitted ... [07:28] Ok, nice :-) [07:28] ... the job goes into pre-stop instead of stopping [07:28] Good. [07:28] the pre-stop script can therefore decide to delay the stop [07:28] That's what I expected. [07:28] or even revert it altogether [07:29] (it won't delay) [07:29] in "pre-stop script", if the job cannot be stopped, just run "start" :) [07:29] The task is set to stopped after post-stop, right? [07:29] there's no "stopped" state [07:29] if you mean when does the stopped event get emitted, that is after post-stop, yes [07:29] Yes. [07:29] Good. [07:30] the pre-start is ran when? [07:31] just before the start itself, right? [07:31] with the starting event emitted, or no? (vetoable?) [07:31] and the started is after post-start? [07:31] I'm reading the graph right? [07:32] starting is emitted [07:32] then pre-start is run [07:32] then the "exec"/"script" process (if any) is spawned [07:32] then post-start is run [07:32] then started is emitted [07:32] -- [07:32] pre-stop is run [07:32] then stopping is emitted [07:32] then the "exec"/"script" process (if any) is killed [07:33] then post-stop is run [07:33] then stopped is emitted [07:33] What about when pre-start vetoes? [07:33] -- [07:33] Is the stopping emitted? [07:33] if pre-start runs "stop", then you get stopping and stopped emitted [07:33] Hmm... [07:33] (red line out of pre-start) [07:33] Bad for my health :P [07:33] I'd just like to veto a start [07:33] Go back to waiting then deleted maybe... [07:34] Some way. [07:34] So that whichever got started due to starting event, is there [07:34] tbh, I can't remember why starting/pre-start are that way round, but pre-stop/stopping are the other way around [07:34] (even if it's listening on stopped) [07:35] you can do that in an odd way [07:35] Ah right. [07:35] a fail event [07:35] if you have something that does "start on starting" [07:35] This won't call the stopping, right? [07:35] then it can look at $1, and call "stop $1" :) [07:35] Hmm. [07:36] (the theory is that pre-start's "opposite job" is post-stop) [07:36] Because those Gentoo scripts are pesky and I want to emulate the whole behaviour [07:36] so if you run pre-start, you always need to run post-stop [07:36] and because post-stop is run, you'd get a stopped event [07:36] so you need some kind of starting event first [07:36] the brokenness is that the deps aren't stopped when the task fails to start [07:36] (e.g. due to checkconfig) [07:37] and since you have a starting event, you also need a stopping event, since some things might run between those two things [07:37] And I'd have to do that in the script itself then :P [07:37] that's possible in upstart [07:37] And can't dep on started :/ [07:37] gentoo-start/failed [07:37] Hmm. [07:37] I know. [07:37] that event will be emitted if the job it tried to start failed to start [07:37] They'd have to depend on both the usual and the failed :P [07:37] Brokenness emulated bug for bug. [07:38] The slash is required, or can I write on started gentoo-start failed? [07:38] or even * there? [07:38] slash is required [07:38] since it's a different event [07:38] Ah, ok. [07:38] Not a problem. [07:39] you could also do something like; exit 1 from pre-start to fail the job [07:39] then you get a "gentoo-job stopping failed pre-start" event :p [07:39] But that wouldn't launch the deps. [07:39] I want to emulate bug for bug :P [07:40] I think I'll go with the "multiple files" approach. [07:41] code duplication all right, but will look more like handwritten code [07:41] the runscript would still have to be modified anyway, to disable its own dep resolution [07:41] right [07:41] dinner [07:42] bbl [07:42] enjoy [07:42] Or is there a way to bypass #! line? [07:42] sure sh -escript [07:42] Great. [07:45] Hmm, even the "when" would be too far [07:45] Just on [07:46] stop on stopping ourdep [07:46] Because that's broken in Gentoo init scripts too :P [07:48] Blah, even better [07:48] I just need to source the given init script [07:48] then call its "start" function [07:48] the more problematic would be reload which some scripts have [07:48] Which doesn't necessarily just restart the app. [07:49] Though that could be just an another handler, e.g. on some parameter [07:49] So you could do: initctl emit xyzzy reload [07:49] or initctl emit xyzzy stop [07:49] Or better, initctl stop xyzzy [07:50] Simple then. [07:50] Just read OPTS variable. [07:51] (gets sourced in) [07:51] the reload is the default one [07:51] If not present, it's just start/stop, will have to emulate that somehow. [07:59] Probably by defining our own bash function, then sourcing. This will override our own definition. [08:02] Wouldn't it be nice to have the reload event separated from restarting, generally? [08:03] E.g. special events "reloading xyzzy" "reloaded xyzzy" [08:04] But then... the reload xyz would just emit these simply and call pre-reload [08:04] reload [08:04] and post-reload [08:04] Actually, just launch a reload event with reloading and reloaded. No need for special syntax :> [08:05] <_ion> That could be useful. Let's ask Keybuk's thoughts about it when he returns. [08:10] Of course, the states would only be emitted if the event had reload in it. [08:12] and add the initctl function reload [08:12] it'd fail if the event wouldn't support it [08:13] s/wouldn't/didn't/ [08:15] could just fall back to stop/start [08:16] or just start if not running [08:30] Temporarily, I'll just create more events [08:31] Actually, I'll use a parameter. [08:31] These become just $1, $2 etc? [08:56] I'm wondering... how to avoid checking filesystems from the same drive in parallel [08:56] Hmm. [08:57] Maybe just something simple... I'd do away with the fstab anyway - it'd be parsed. [09:00] Well, 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 manglings [09:01] LVM can be worked around by parsing lvs [09:01] But don't know about udev... [09:03] <_ion> The 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:04] <_ion> Better ask Keybuk. [09:04] Hmm... or maybe not :P [09:04] Maybe they just punted at the problem - the scanning will just get slower [09:04] Keybuk said he would release an upstart-based init sequence for ubuntu today or tomorrow, we should wait to see what's been done there [09:05] Great, just great. I shall see. === Md [i=md@freenode/staff/md] has joined #upstart [09:05] Uh, yes, md would be problematic too (no, not you) [09:05] :P [09:05] RAID and stuff - you don't know which is on which physical disc. [09:06] Would need physical FS data. [09:06] Hmm... there is an option... [09:06] parsing /proc/diskstats [09:07] Just do a simple read on each of the partitions [09:07] and see which disk's stats got upped [09:07] But that'd have to be done in single mode. [09:09] If one could get a hardware Udev id... [09:09] But then, that doesn't tell us anything about LVM or RAID. Though these can be worked around. [09:10] wasn't upstart supposed to be crossplatform? i'm quite sure that /proc/diskstats is nonexistant on bsd's, even with linprocfs mounted on /proc [09:10] well [09:10] this would be in the job files [09:11] which are distro specific [09:11] :> [09:11] oh, ok [09:12] Ok. [09:12] udevinfo returns the hardware ID. [09:12] One problem less. Now I'll check the LVM. [09:17] Hmm, udevinfo is useless against LVM or RAID. [09:17] But these fortunately have their own tools. RAID has mdstatus [09:17] LVM has lvs === theCore [n=alex@ubuntu/member/theCore] has joined #upstart [09:18] The parsing would be done by a special util, so as not to slow down the startup. Will write such a script now. [09:21] lvs+pvs for LVM (converting to physical device), udevinfo for physical volumes [09:21] Don't remember md, so it'll have to wait. [09:22] I think you are looking for /lib/udev/vol_id [09:23] <_ion> Ubuntu 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] Md, that's one thing. [09:24] No, udevinfo will be enough. [09:24] vol_id requires the device path, so it's useless. [09:24] _ion, what does that do? [09:24] Knowing the device path means I know everything. [09:25] For knowing the LVM volumes, one just needs to run vgscan - and that's needed anyway [09:26] vgscan, then parse lvs and pvs info [09:26] then we get the device name. [09:26] Which can be probed using udevinfo --name=device --query=env [09:26] to get the unique hardware id [09:27] <_ion> alexextreme: If you run /lib/udev/watershed sleep 2 twice, the other one won't be started until the first one has finished. [09:27] ah [09:27] Even better :> [09:28] One can just do some ls on sysfs [09:28] to get where the device mappings are stored [09:28] I'll see the libsysfs [09:30] Yes, there is a tool in sysfsutils [09:30] systool [09:32] But why depend on an external tool, when few ls or finds will suffice? [09:32] *a few [09:33] The basic partitions are just subdirs of the drive subdirectory [09:34] the device mappings are on their own, but they have the parition(s) they're contained in symlinked in slaves subdir [09:35] Also, the partitions/discs have the symlink to the mappings in holders [09:35] subdirectory [09:36] Simple enough to write a script to detect that in realtime. [09:38] Only swap partitions will have to be ignored... [09:39] (/proc/swaps) [09:39] Bah, can't use /proc/swaps. [09:39] The entry won't be there yet, the swap isn't enabled. [09:40] <_ion> Yay, i booted my computer using upstart 0.3.5 + my watch_delayed patch. It works. [09:40] The simplest would be to create fsck.swap, which does nothing. [09:43] How does one detect that a partition is swap in Linux? :> [09:43] w/o trying to mount it [09:45] Ah, right. [09:45] mount -f -v [09:46] Blah, that does print unknown only [09:46] Any ideas? === arachnis1 [i=arachnis@088156186027.who.vectranet.pl] has joined #upstart === arachnis1 is now known as arachnist [10:00] you do not want to look in /etc/fstab? I mean there could be swap partitions that I do not want to use [10:01] hmm [10:01] just installed herd 2 in vmware from an iso i downloaded a while back [10:01] "only" 409 updates :p [10:03] night === arachnis1 [i=arachnis@088156186027.who.vectranet.pl] has joined #upstart [10:04] night === 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 [10:21] Blah, it's just a syscall, that swapon. [10:35] Heh, the first page of swap contains a magic ID [10:36] SWAP SPACE for old swap [10:36] SWAPSPACE2 for newer one [10:36] SWAP-SPACE for old [10:36] old is unsupported in 2.6 AFAIK anyway, so we don't have to bother. [10:36] The only thing I have to know is current page size. [10:39] Now, the idea is - can I get the pagesize w/o launching any C code? :P [10:39] (that and some head+tail would be enough for basic detection) === AStorm [n=astralst@host-81-190-179-124.gorzow.mm.pl] has joined #upstart [10:51] In case of problems, I'll just punt and check the largest pagesize [10:54] Ah, it should be in the libc headers. [11:00] Ok, it's in Linux :P [11:00] The largest number of bytes is 1 << 22 [11:00] That's some kind of sparc64 [11:00] Usually it's 1 << 12 or 4096 [11:01] 1 << 22 is... 4MB! [11:01] Now that's some page :> [11:04] I'd like to avoid grepping 4 MB of the swapfile, but oh well :P [11:16] head -n 4m | grep -U SWAPSPACE2 is ok... but.. [11:17] I think that trying to swapon would be faster than that... [11:17] though the simple check would be faster if I could somehow get the page size [11:17] or write a tiny C prog "isswap" [11:48] <_ion> Keybuk's dinner has taken a while. :-) [11:51] Right. [11:51] And I've finished that swap detector [11:51] as a bonus, it detects old v1 swap space as non-swap [11:51] so will bork :-) [11:51] A special return code of 2 [11:51] 1 if not swap space [11:51] 0 if swap space v2 [11:52] 254 for file open error [11:52] 255 for argument error [11:52] No usage (quite obvious - give it a device name) [11:53] Uses mmap for extra speed :P [11:53] <_ion> In 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.diff [11:54] <_ion> It compiles with the libnih from https://code.launchpad.net/~ion/+branch/libnih/watch-delayed