/srv/irclogs.ubuntu.com/2009/02/23/#upstart.txt

=== sadmac_ is now known as sadmac
MarcWeberDoes it make sense to you introducing init --expected-pid=2 ? Why? I'm trying to run nixos on a vserver. I can't replace the default init so I have to run upstart using PID 2. Of course I can patch those two lines. But maybe other people do have this problem as well ?20:59
KeybukUpstart depends on being pid 120:59
Keybukand it expects the special behaviour afforded that process by the kernel20:59
MarcWeberThat's bad news. the vserver even starts without /sbin/init.. So I can't change that so I can't use upstart without heavy patching?21:00
MarcWeberKeybuk: can you estimate the amount of work required to make this possible? I mean a PID 2 should be able to run jobs as well. (Maybe its killed by PID3 .. I think I must live with that..)21:02
MarcWeberMaybe the solution is to try yet another hosting provider..21:03
Keybukpid 2 would not have daemon process children reparented to it21:03
Keybukwhich has always been a specific goal of upstart's to support21:03
MarcWeberHmm I think I have to dive into some documentation first to understand that.21:04
Keybukwhy can you not replace the existing pid #1 ?21:05
MarcWeberCause I don't have control over pid #1. All it seems I can do is providing runlevel code. And thats pid > 1. But can send another ticket to clarify that..21:06
Keybukwhy don't you have control over it?21:06
MarcWeberbecause cat /proc/1/exe  results in permission denied. I don't where the file is. It's a virtual server.21:07
MarcWeberOr do you have any idea how to find the location other then find . -name "init" (which showed only /sbin/init which isn't executed at all)21:08
MarcWeberIf a process starts another doesn't the kernel setup a parent -> child relation automatically?21:09
Keybuksurely you have control over the distribution you installed?21:09
MarcWeberKeybuk All files but /dev/* I can't mknod21:10
MarcWeberI can start a repair system. This way I can access /vserver containing all files.21:10
Keybukyou're a nixos developer?21:10
MarcWeberWhen do you call somone a developer? I've been a contributor for over a year now. I haven't written much of the core C(++) code though.21:11
MarcWeberAnd we already talked about a similar problem a year ago. That time I tried setting up upstart-0.5. I had to patch it cause the other hosting used a kernel not providing a feature..21:12
Keybukare you attempting to replace sysvinit in nixos with Upstart?21:12
MarcWebernixos has been using upstart-0.3 for years21:13
Keybukand when installed into a vserver, its pid isn't 1?21:13
MarcWeberEelco (core developper) told me he wants to start an upstart-0.5.1 branch now21:13
MarcWeberI don't know how to tell the vserver to run upstart at all :-(21:13
Keybuk:-/21:14
* Keybuk has heard of problems with vserver before21:14
KeybukI've had arguments with vserver upstream in fact21:14
Keybukover things like vserver failing to provide init with the special signal handling it expects21:14
Keybukwhich suggests that you can run upstart as init/pid #1 in a vserver21:14
MarcWeberKeybuk: Can you tell me briefly why I want this reparenting or can you give me some keywords so that I can google it up?21:15
KeybukMarcWeber: supervision of daemon processes21:15
MarcWeberThe first hosting provider lets me use /sbin/init. The trouble is that I can't use recent coreutils. That means that all software packages hashes would change. This means I can neither use nor provide binary packages.. So I know that some vservers can use #1.21:17
MarcWeberReparenting = if a daemon dies its subprocesses are reparented to be direct childs of init so that init (upstart) can kill them ?21:25
Keybukexactly21:36
Keybukand more to the point21:36
Keybukso init (upstart) is notified when they die21:36
MarcWeberSo that it can restart the process. looking out wether a pid 10 still exists won't work cause the kernel might have given pid 10 to another process ?21:37
Keybukno, more than that21:38
Keybukupstart will never know that pid 10 has exited21:38
MarcWeberIt could try to find pid 10 10 times a sec..21:38
sadmac2eew.21:38
MarcWeberBut that's no option.21:38
MarcWeberSo I'll look for yet another hosting service..21:39
sadmac2Keybuk: I have a good chunk of a replace-nih-config-with-bison patch. Its pretty ratty but worth a guided tour. How long will you be around today?21:41
Keybuktoday is not a good day21:42
sadmac2rgr21:43
MarcWeberWhat's wrong with waitpid to get notified when a child terminates?21:50
sadmac2MarcWeber: only tells you /your/ children. we need to know about the /daemon/'s children. grandkids21:51
MarcWeberOk. Then I was right.21:52
Keybuksadmac2: ok, let's look at your patch ;)21:57
sadmac2Keybuk: err... its kind of at home and in pieces. I was hoping to do it in about an hour :)21:58
Keybukcan I tell you my mad idea first?21:58
sadmac2ghead21:58
sadmac2Keybuk: still here?22:07
Keybukyup22:09
Keybukso you know how "initctl start" and "initctl stop" are just commands that muck around with the job state directly22:09
Keybukwhat if they weren't?22:09
Keybukby that I mean22:09
Keybukif I do "stop somejob", the job stops22:09
Keybukand if I reboot22:09
Keybukthe job is still stopped22:09
Keybukand if I do "start someotherjob" to make a new copy22:09
Keybukwhen I reboot, that is started again22:09
sadmac2Keybuk: how do you handle single user mode?22:11
Keybukno plans there22:11
sadmac2I think you might be having those "neat when everything's running normally" type ideas. Hard to bootstrap, hard to deal with in an inconsistent state.22:12
sadmac2Keybuk: actually, it could work.22:27
sadmac2Keybuk: so things like single user mode would be done by just specifying which set of enabled services you want on the command line (out of a series of configured choices). start/stop would affect whichever was active22:28
sadmac2so its just a matter of making /etc/init/enabled_services_foo-mode /var/lib/*/enabled_services_foo-mode22:29
Keybukwell22:29
Keybukthat's basically what I was thinking22:30
Keybukstart <instance> would add a file in /var/lib/init that morally said that the particular instance should be auto-started22:30
Keybuk(assumedly it was manual before)22:30
Keybukstop <instance> would add a file saying that it should not be auto-started22:30
Keybukstart <creating a new instance> would create a new job file in /var/lib/init for the new instance, specifying the conditions in which it runs (from the cmdline)22:30
sadmac2I assume one would add and one would remove :)22:31
MarcWeberWhat actually happens when a child of a daemon exits?22:42
sadmac2MarcWeber: if the daemon is still running, then nothing.22:43
sadmac2MarcWeber: if the daemon dies, then its children get inherited by pid 1 (always pid 1, whatever that may be).22:45
MarcWebersadmac2: Example: mysqld dies but has still one serving process. What should happen? (same for apache or such)22:46
MarcWeberof course the daemon should be restarted.22:46
sadmac2MarcWeber: they get reparented to pid 1, which may then wait on them22:47
MarcWeberWhen does upstart get to know about them? Whet those daemon child processes are created or when the daemon dies?22:48
MarcWeberI'm trying to figure out wether I neet this upstart feature or not. I mean a lot of distributions still do use a traditional init..22:49
sadmac2at the moment never :) upstart just sees them as wayward userspace processes when it inherits them. Working with kernel folks on a solution (0.5.* uses ptrace to monitor the daemon as it runs and capture its calls to fork() thus finding out that way)22:49
sadmac2a service is considered dead by upstart when it has no more processes.22:50
MarcWeberso a traditional init does restart services to early.22:51
sadmac2a traditional init doesn't restart them at all :)22:52
sadmac2well it can, but for most larger things it doesn't22:52
MarcWebersadmac2: I've tried it. apache is not restarted if you kill it. However writing a wget /curl cron job test running apachectl {stop,start} would take me less than a minute.23:12
sadmacKeybuk: I'm at home now. still interested in this code/having mad ideas?23:12
Keybuksadmac: sure23:26
sadmacKeybuk: http://sadmac.fedorapeople.org/parse_job.y23:31
sadmacI don't seem to have the ignore rules right to get it to not look at generated files and otherwise do what it should, but basically that replaces parse_job.c23:31
sadmacthen we get some makefile.am changes and some changes to the test cases to account for the slightly altered error reporting.23:32
Keybukslightly altered?23:32
sadmacmost errors end up turning into UNEXPECTED_TOKEN the way things are written. This can change though.23:33
sadmac(unfortunate part about that error, when isn't it true?)23:33
Keybukright, I think I ran across that before with bison23:35
KeybukI notice you're having token issues there23:35
Keybukisn't it normal to use flex to write the lexer/tokeniser then pass that to bison?23:35
sadmacI kinda figured the lexer would be too simple to bother. Oops. :)23:36
Keybukis there any bits of syntax that are "hard" to do this wya?23:36
sadmaccontext-sensitive keywords23:36
Keybukhow so?23:37
sadmacfor example, with nih_config "start on start" is valid. the second start isn't a keyword anymore, it becomes an event name.23:37
Keybukisn't that just23:37
sadmacits very doable, the problem is it can't be done categorically. every keyword needs a (one line) mention that it promotes to string when asked.23:38
Keybukstart_on := "start" "on" EVENTTREE23:38
KeybukEVENTTREE := "event" | EVENTTREE "or" EVENTTREE | EVENTTREE "and" EVENTTREE23:38
sadmacthe other thing that was hard was allowing event operators to have linebreaks BUT only inside parenthesis. My solution to that isn't final23:38
Keybukerr s/"event"/EVENT/23:38
KeybukEVENT := NAME ARG*23:38
Keybukheh, pythonic parens ;)23:39
Keybukrandomly23:39
Keybukit's probably quite easy to parse the syntax in lua ;)23:39
sadmacugh. lua is scary.23:39
sadmacthat doesn't solve it23:39
sadmacwhat type is NAME?23:39
Keybukthat's a type23:40
sadmacwhen you say "start" in bison, you declare a new type. a token with name "start" is of type "start"23:40
Keybukit can be a bare word, or a single or double-quoted string23:40
KeybukARG is the same23:40
sadmacso what we23:40
sadmacwhat we'd need is a line like this23:40
sadmacSTR := LITERAL_TOKEN | "start" { $$ = "start" } | "on" { $$ = "on" } | "stop".....23:41
sadmacthe easier, and better option is to just say "keywords are keywords" and make users quote them.23:42
Keybukhow do you mean?23:42
sadmacstart on start --> syntax error23:42
sadmacstart on "start" --> ok23:42
Keybukthat third one can't be start23:42
Keybukit's not at the start of a line23:42
Keybukkeywords only appear at the beginning of a line23:43
sadmacKeybuk: the problem is the type23:43
sadmacKeybuk: when "start" appears in the bison grammar, that isn't a string23:43
sadmacthat is a "start".23:43
sadmacits its own type23:43
Keybuksurely type depends on context?23:43
sadmacnot for tokens23:44
sadmacnot for the output of the lexer23:44
sadmacyou can create the hierarchy, but its a lot of text.23:44
sadmacbecause each keyword is a different type. There's no way to apply the promotion to them categorically.23:44
sadmacremember, when the lexer sees "start" it has to decide what type it is23:45
Keybukthat sucks ;)23:45
sadmacand the lexer doesn't maintain state other than file position. it has no idea what came before23:45
sadmacKeybuk: it does... but then I could put that in and several other things and all this would still be less code than the old parse_job.c. AND there'd be no more nih_config23:46
Keybukwhat's the difference in resulting code though?23:46
Keybukand any difference in speed?23:47
sadmacdidn't look in difference in resulting code. speed seems uncanny. tests run faster than my terminal can write the results.23:47
sadmacthe resulting code isn't that interesting here, since you never read it. they put in all the #line macros so the errors are reported against the original .y23:49

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