/srv/irclogs.ubuntu.com/2008/03/19/#upstart.txt

Keybukanother idea00:24
Keybuk  req = com.ubuntu.Upstart.Request ()00:24
Keybuk  job = FindByName("apache")00:24
Keybuk  dbus.AddMatch(req, "StatusChanged")00:24
Keybuk  instance = job.Start(env, req)00:24
Keybukor I guess00:33
Keybuk  job = FindByName("apache")00:33
Keybuk  req = job.Request()00:33
Keybuk  dbus.AddMatch(req, "StatusChanged")00:33
Keybuk  req.Start(env)00:33
Keybukbasically pre-alloc the Request object00:33
=== AlexExtr` is now known as AlexExtreme
Keybukoh, DBus10:48
* Keybuk has a KHAAAAAAAN! moment10:48
Amaranthso are you writing your own libdbus now? :)10:48
Keybukbasically10:48
Keybukwell10:48
Keybuklibnih-dbus10:48
Keybukwhich wraps libdbus and makes it less itchy10:49
Keybukhttp://people.ubuntu.com/~scott/nih-dbus.png10:54
Amaranthneat, didn't realize you were that far11:09
Amaranthbut i thought libdbus aborted when the daemon went away11:09
KeybukI fixed that11:18
Amaranthhow? :)11:20
Keybukreimplemented dbus_bus_get()11:20
Keybukotherwise it's just a flag in the struct you leave as FALSE11:20
Amaranthah, neat11:21
Keybukat the point of chaining everything together11:22
Keybukso you do something like:11:22
Keybuk  NihDBusInterface job_interfaces[] = {11:22
Keybuk      IFACE_JOB,11:22
Keybuk      { NULL }11:22
Keybuk  };11:22
Keybuk:11:23
Keybuk  nih_dbus_register_object (job, job_path (job), job_interfaces);11:23
KeybukIFACE_JOB, and all the necessary marshalling functions, are generated by a python script11:24
Keybukso you just need to define11:24
Keybuk  job_start() and job_stop(), etc.11:24
Keybukwhich have C-like arguments and return values11:24
Amaranththat's pretty neat11:24
Keybukmain problems are the difference in interface style ;)11:26
Keybuke.g. that function creates an NihDBusObject struct, holding the path, interface array and underlying object11:26
Keybukfor bus, that needs a vtable structure - the message function is a standard one inside libnih-dbus that knows how to dispatch based on the interface array11:26
Keybuk(and handle the Introspect and Properties interfaces)11:27
Keybukthe unregister function is a standard one as well11:27
Keybukso when the connection vanishes, it calls nih_free() on the object11:27
Keybuk*but* that means if you call nih_free yourself, the destroy function has to unregister the object11:27
Keybukwhich calls the unregister function11:27
Keybukwhich is nih_free11:27
Amaranthi think i'll just keep using dbus from python :P11:27
Amaranthi thought nih_free just lowered the reference count11:28
Keybukno, nih_alloc isn't refcounting11:28
Amaranthah11:29
Keybuksome bits of dbus seem a bit broken to me11:31
Keybukor, at least, poorly designed11:32
Amaranthyou say that about everything, i think :P11:32
Keybuklike the fact you can't share an object table between multiple dbus connections ;)11:32
Amaranthmultiple connections? why would you have multiple connections?11:32
Keybukone to the bus11:33
Keybukand one for when the bus isn't there11:33
Amaranthah, for initctl?11:34
Keybukright11:34
Keybuktry:11:35
Keybuk    bus = dbus.SystemBus()11:36
Keybuk    manager = bus.get_object("com.ubuntu.Upstart", "/com/ubuntu/Upstart")11:36
Keybukexcept:11:36
Keybuk    server = dbus.connection.Connection("unix:abstract=/com/ubuntu/Upstart")11:37
Keybuk    manager = server.get_object("/com/ubuntu/Upstart")11:37
Amaranthneat11:37
Keybukthough in practice, most things will be discouraged from doing the fail-over11:38
Keybukit's mostly just for initctl, so if dbus is down, you can either start dbus - or shutdown the machine11:38
Amaranthi can't think of anything else that would need it11:38
Keybukme neither11:38
Amaranthwell, i'm sure people will _think_ they should use it11:39
Amaranthbut you can just tell them to quit being stupid and start the system bus :)11:39
Keybukyeah11:39
Keybuk*sigh*14:39
KeybukD-Bus needs a lot of glue14:39
jdongyou could write an UpstartBus and expose some Dbus compatibility mode for a few release cycles ;-)14:40
jdongyou know that sounds tempting14:40
jdongthen the KDE4 folks will have a real world justification for their dbus abstraction layer!14:40
Keybukwe had an upstart-native IPC before14:41
Keybukthat's what I'm trying to get away from14:41
Keybuk:p14:41
jdongKeybuk: What kind of {pre/post}-start/stop events are available to me in Hardy's upstart?14:44
jdongare post-start and pre-stop logical/existent?14:44
Keybukyes14:44
jdongcool14:45
jdongKeybuk: so when 5 jobs "start on stopping bar" and I do initctl stop bar, what is the order of actions that happen from that with regards to pre-stop/post-stop scripts on bar?14:46
Keybukpre-stop will be run14:47
Keybukthe stopping event for the job will be emitted14:47
Keybukthat event blocks14:48
Keybukthe main process of the job will be killed14:48
Keybukpost-stop will be run14:48
Keybukthe stopped event for the job will be emitted14:48
jdongKeybuk: beautiful and logical14:48
Keybukno order between the individual 5 jobs is guaranteed14:49
jdongsounds reasonable.14:49
Keybukbut between the 5 jobs and bar *is* guaranteed14:49
Keybukbar will not actually be killed until the 5 jobs have started14:49
jdongKeybuk: in  your replacement-initscripts, is there any reason you chose to not use a service and pre-start/post-stop for readahead, readahead-watch, and other non-daemonized stuff?14:52
Keybukhow do you mean?14:52
jdongKeybuk: like in readahead, you used a single "exec readahead-list blah", while I probably would've used "service; pre-start script readahead-list blah"14:53
Keybukwhy would you do it in pre-start ?14:54
jdongKeybuk: so that way readahead shows up as "started" and I can say "start on started readahead" which makes more sense to me than "start on stopped readahead ok"14:55
jdongKeybuk: is there something insane about doing it in pre-start?14:55
Keybuknot really insane, per-se14:56
Keybukit's certainly one way to do tasks14:57
Keybukthough "started readahead" implies readahead is still ongoing to me14:57
Keybukwhereas "stopped readahead" says that the readahead has actually finished14:58
Keybuk(the "ok" is arguably a bug, it shouldn't matter whether it worked or not <g>)15:00
sadmac2Keybuk: We'll be needing to document the 0.3.9 job format soon.15:00
Keybuksadmac2: happily that's pretty stable ;)15:02
Keybukobviously it all changes in 0.5 again <g>15:02
sadmac2well that'll be nice15:03
sadmac2I'm just hoping I don't miss any features.15:03
jdongKeybuk: lazy question of the day: Is there syntactic sugar for restarting services yet?15:14
Keybuknot yet15:16
Keybukit's actually more than sugar15:16
Keybukrestart has different behaviour than stop && start15:16
sadmac2bounce <job>15:17
* sadmac2 would be very happy if the command were called bounce15:17
Keybukheh, why? :)15:18
Keybukwouldn't that clash with MTA commands?15:18
jdongbecause he can create innuendos with jobs like "fsck"15:18
sadmac2jdong: you're one to talk, what with having dong in your name and all15:18
jdongnot like he can't do that right now, already.15:18
* jdong goes down the road of greedy boot speed optimization.15:18
* jdong plays with nice/ionice :)15:19
sadmac2Keybuk: bounce is a pretty ubiquitous colloquial term around here for restarting something.15:19
* Keybuk wonders whether it's against the rules to name a computer after a game that's not yet been released16:01
sadmac2Keybuk: what game?16:42
Keybukspore16:47
Keybukmakes a good machine name16:47
Keybuk(my naming scheme is computer game names)16:47
sadmac2Keybuk: the firewall has to be named Portal.16:48
sadmac2I name mine after postmodernists16:48
sadmac2Baudrillard, Warhol, Foucault16:48
Keybukheh, the firewall used to be frontier ;)16:49
sadmac2The windows box should be Solitare16:50
sadmac2(sp?)16:50
sadmac2s/tar/tair/16:50
Keybukyeah, used that one a few years ago16:51
AlexExtrememine are named after characters from The Matrix16:51
Keybukit was replaced by minesweeper and now is hearts16:51
mdalesI have a quick question. If I remember correctly upstart will blacklist any script that fails too frequently within a given period16:52
mdalesat any point does that blacklisting expire?16:52
Keybukdepends on the period16:53
Keybukit's a rate limit16:53
Keybukif you say a job can only respawn 10 times a minute, then it cannot respawn within a minute of the first of 10 respawn attempts16:53
Keybukthe default is 5 times in 10 seconds16:54
mdaleshmmm16:54
mdalesokay16:54
mdaleswhat's happening here is an ubuntu system has had a bad udev rule added that means a job is being invoked too early in the boot process, rather than waiting for runlevel 216:54
mdalesso it fails, then at runlevel 2 the rule is no longer available16:55
Keybukwhich "here" is this?16:55
Keybukudev doesn't emit any upstart events in Ubuntu16:55
mdalesit's a gutsy system that I don't have ssh access too, just through the software that is started by this upstart job16:56
Keybukwhat software is that?16:56
mdaleswell, that's the pain - someone accidently made udev to it16:56
mdalessome remote management software I wrote16:56
Keybukright16:56
Keybukand that crashed?16:56
mdalesI imagine the software crashed as the world wasnt' ready. the udev rule restarts the software on block devices (intended for USB stick configuration)16:57
Keybukok16:57
mdalesso I assume it's being started on hard disks :)16:57
Keybukdefinitely would be, yes16:57
mdaleswe get an unknown job error on the system we've reproduced the error on here16:58
mdalesbut I was wondering if we waited long enough that would go away16:58
Keybukunknown job is odd16:59
Keybukthat means the name isn't right?16:59
Keybukthey're only stopped if they run out of control16:59
Keybuknot deleted16:59
mdaleshmmm17:00
mdalesthe script is still there and is valid17:00
mdalesI say, the runaway invocation was just a theory17:01
Keybukdoes status not show it?17:01
mdalesinitctl list does not show it17:01
Keybukwhat happens if you touch it?17:01
Keybuktouch /etc/event.d/myjob17:01
Keybukdoes it show up in list?17:01
mdaleslet me see17:01
mdalesyes17:02
mdalesit does17:02
KeybukUpstart thinks you deleted the file17:02
mdalescool :)17:02
Keybukis it changed at all on boot?17:02
mdalesno17:02
mdalesthe only thing this udev script does is call start and stop17:03
Keybukweird17:03
mdalesin that it tries to stop an existing thing and then start it17:03
KeybukI'd boot with --debug to see what's going on17:03
mdaleswill give that a whirl. but I'm assuming my theory that the job would become avaiable over time is bogus then?17:03
jdongKeybuk: does Upstart log anywhere?17:04
jdongI think I have a race on boot :)17:04
Keybukto syslog17:05
Keybukmdales: right, it won't become available if Upstart has wiped it from its memory17:05
jdongKeybuk: does console output imply not console logged?17:09
Keybukconsole logged is broken17:12
jdongKeybuk: would that be why /var/log/boot is empty?17:12
Keybukyes17:12
jdongcool :)17:12
mdalesnot much new info on debug. I can see that on start the process in question respawns and then terminates a lot17:13
Keybukodd that upstart deleted it though17:14
Keybukit should mention that17:14
mdalesI can't see it - is there a specific term I should be scanning for in the logs?17:14
Keybuk"deleted" is a clue ;)17:15
Keybukthere should certainly be something like:17:16
Keybuk  Deleting foo job17:16
mdalescd /var/log; grep elete *  | grep job shows no results17:16
Keybukdid you look at the output on the screen?17:16
Keybukit might be happening before syslog starts17:17
mdalesah. alas it scrolls off too quickly17:17
mdales25 lines really isn't enough :)17:19
mdalesokay, so this is interesting. I actually start two processes, the second dependant on the first. it's the first that's being deleted. I note the second gets too many restarts, but the first only seems to be started once17:20
mdalesther'es a terminate message, then silence17:20
mdalesthis was a reboot without debug17:21
ion_We really should move the drivers from Xorg to the kernel, have it provide a good framebuffer interface with acceleration, resolution settings et al, and have the virtual consoles as well as X use the same framebuffer interface in harmony. :-)17:22
mdalesheh17:22
mdalesI assume then it says job terminated with status 2 the 2 is the exit status for the process17:22
ion_That would also make it possible for X to break horribly and still have a working console, or even a kernel’s debug console you get with a magic sysrq key over virtual consoles as well as X.17:23
Keybukmdales: yes17:23
Keybukion_: it makes it possible to panic the kernel and do something more useful than flash the caps lock light ;)17:23
Keybuk(I kid you not, this is in keithp's use case list)17:23
ion_Yep :-)17:23
* AlexExtreme hates not getting panic info when in X17:24
AlexExtremebtw, is kdump going to be used in ubuntu any time soon?17:24
ion_I don’t even have a caps lock light. :-)17:25
mdaleswith --debug there's just too much crap17:28
mdaleswell, many thanks for the assistance. if I find any more info I'll file a bug perhaps :)17:30
Keybukdo you know, I think I just won?17:40
Keybukstill need to handle new connections, disconnection and properties17:41
Keybukbut the basics are there now ...17:41
ion_Congrats. :-)17:41
ion_You tamed the beast.17:41
Keybukheh, I've stopped it biting me17:42
KeybukI haven't yet got a saddle on it17:42
ion_Heh17:44
Keybukof course, now to decide which bit to attack next18:08
* sadmac2 attacks the crab's weak point for massive damage19:53
sadmac2ion_: there's quite a few X developers here at RH that want to do what you want to do with X, and similar things.19:57
* Keybuk wonders21:28
sadmac2...???!!!21:28
sadmac2what? what?21:28
Keybukwhich bit to do next21:30
sadmac2Keybuk: what are the options?21:30
Keybukstill just plodding on with the dbus stuff21:31
KeybukI guess I need to work on the python script to auto-generate the bindings21:31
sadmac2which bindings are those?21:34
Keybukbasically just C marshalling functions21:35
Keybukto turn DBusMessage into a function call, and vice-versa21:35
sadmac2auto-generating code makes kitty scared. But I won't judge without seeing.21:35
Keybukreally?21:36
Keybukauto-generating code is the *best* way to do things21:36
Keybuksince then you only need test the generator21:36
sadmac2The better way is to be really smart about de-duplication, so you just don't have to write much code.21:37
Keybuksadly the C compiler doesn't yet support runtime-generated function calls ;)21:37
sadmac2I suppose the cpp is auto-generation though. And I do love the cpp.21:37
sadmac2well, you'd still have to do the generating before compile time, wouldn't you?21:38
Keybukit doesn't even support that21:38
sadmac2I dunno. I'd need a fuller picture of what's going on.21:39
Keybukint21:40
Keybukhello_world (const char *who,21:40
Keybuk             const char **str)21:40
Keybuk{21:40
Keybuk    sprintf (*str, "hello %s", who);21:40
Keybuk    return 0;21:40
Keybuk}21:40
Keybukideal C code for a D-Bus method with the IDL21:41
Keybuk  com.netsplit.Nih.Test.HelloWorld (in String who, out String str)21:41
Keybukto be able to make the code that simple, you need a function to marshal a DBusMessage into a function call21:41
Keybukand form a valid reply as well21:41
Keybukpeople.ubuntu.com/~scott/test_dbus.c21:42
Keybukerr21:42
Keybukhttp://people.ubuntu.com/~scott/test_dbus.c21:42
Keybuktest_hello () there is the example of the simple function I'd like to spend my time writing21:42
Keybukthe test_hello_marshaller () function makes it possible by marshalling the message21:43
Keybukand the test_hello_args, test_methods, test_signals, test_properties and test arrays connect it all together21:43
KeybukI'd like everything but test_hello() to be autogenerated21:43
Keybuksince it's entirely based on the iDL21:43
sadmac2I see.21:44
sadmac2I think I could get nearly there using just the cpp.21:44
Keybukit'd be quite difficult21:44
sadmac2:) I was damn close to having try {} catch {} blocks implemented in the cpp.21:44
sadmac2sigsetjmp was behaving oddly though.21:45
Keybukyou can certainly do exceptions in C21:45
Keybukcf. dpkg21:45
ion_A human can be considered a code generator. :-P21:57
ion_Or perhaps a caffeine to code converter.21:57

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