/srv/irclogs.ubuntu.com/2016/08/23/#upstart.txt

fedora_newbI am trying to start multiple services with another service. However, I am having a hard time of getting it setup. I keep getting unknown job attendance. However, I can start attendance outside of the control no problem. http://pastebin.com/zN9fP0Gr05:12
=== fedora_newb_ is now known as fedora_newb
AnrDaemonfedora_newb: You should use events to manipulate job start. Never call "initctl start" directly without a good reason. A VERY good reason, and even then - don't.09:14
AnrDaemonIf all you need is to change the start parameters of another job, make an .override with desired "start on" clause.09:15
=== JanC is now known as Guest58470
=== JanC_ is now known as JanC
ruptwelveHello Upstart peoples19:30
ruptwelveIs anyone around to assist with a question I have ?19:30
ruptwelveRegarding script stanzas and exit codes19:30
ruptwelveThe issue I am having is parsing errors from apache startup19:31
AnrDaemonruptwelve: What specifically you are "parsing" ?20:21
ruptwelveSo20:21
ruptwelveI have an upstart config 20:21
ruptwelvethat runs httpd with some arguments20:21
ruptwelvewhen I run initctl start httpd I get the message: httpd start/running PID xxxx20:22
AnrDaemonWant an advice? Ditch as many "arguments" as possible.20:22
ruptwelveRegardless if the apache server started or not 20:22
ruptwelveright20:22
ruptwelveso event if I run just /usr/sbin/httpd 20:22
AnrDaemonTell apache to not daemonize.20:22
ruptwelveShould I get an exit code ?20:22
AnrDaemonYou ALWAYS get an exit code, when program exits.20:23
ruptwelveright20:23
ruptwelvebut I always get a 0 20:23
ruptwelveeven if Apache did not start20:23
AnrDaemonYes. So, again.20:23
AnrDaemonFFFFFFFFFFFFFFF20:24
AnrDaemon1. If you are delegating all active scripting to other daemons or running mpm-itk, tell apache to not daemonize.20:25
AnrDaemon2. If you are using active content filters, then see cookbook, "tracking the wrong PID".20:25
AnrDaemonIn either case, do not test it on live system.20:26
ruptwelveThis is not a live system so that is fine20:26
AnrDaemonAnd always ensure that initctl status reporting "stopped".20:26
ruptwelvewhat I am trying to achieve here is to be sure weather apache did start or not20:26
AnrDaemonBefore starting the job again.20:27
ruptwelveRight20:27
AnrDaemonupstart will manage that by itself, once you set up PID tracking correctly.20:27
AnrDaemonI hope you do not use any wrapper scripts?20:27
ruptwelveAllow me to paint  a picture 20:27
AnrDaemonBetter pastebin your job script :)20:28
ruptwelvesure one sec 20:28
AnrDaemonThat would be an image worth 1000 words.20:28
ruptwelveso20:31
ruptwelvehttp://pastebin.com/raw/CUYkRcGX20:31
ruptwelvethat is httpd.conf20:31
ruptwelveunder /etc/init/20:31
AnrDaemonUse exec. Not script.20:31
AnrDaemonAnd use upstart to set ulimits.20:32
AnrDaemonAnd other vars.20:32
ruptwelveAnd this is a part of the /etc/init.d/httpd 20:33
ruptwelvehttp://pastebin.com/raw/ZTCBNNBu20:33
ruptwelveWhich triggers initctl 20:33
AnrDaemonIf you have init/httpd.conf the init.d/httpd will only be called by idiots and degenerates.20:34
ruptwelvewell20:35
AnrDaemon"service" wrapper will find upstart/systemd scripts before init.d20:35
ruptwelveright20:35
ruptwelvebut even if just using initctl 20:35
AnrDaemonJust make sure you update-rc.d -f apache2 remove20:35
AnrDaemonOk, to reiterate:20:36
AnrDaemon1. You're using wrapper script. Thus making the job of finding the right PID to track unnecessarily hard.20:36
AnrDaemon2. You're using runlevels instead of proper signals. start on local-filesystems and net-device-up IFACE!=lo is usually sufficient.20:37
AnrDaemonAlso remove any "respawn" stanzas until your job is tracking the right pid.20:38
ruptwelveOkay! Thank you for clearing some stuff up AnrDaemon 20:38
ruptwelveBut I still don't understand why I cannot just get an exit code other than 0 from the initctl script ?20:39
ruptwelveEven if  I just run exit 1 20:39
ruptwelve"exec exit 1" 20:39
ruptwelveif I run initctl start httpd 20:40
ruptwelveecho $? 20:40
ruptwelveI will always get 0 20:40
AnrDaemonBecause "initctl start ..." sends signal to init daemon, and if signal is sent all proper, the exit code is a success.20:41
ruptwelveright 20:41
ruptwelveThat makes sense 20:41
AnrDaemonAlso I'm not sure "exit" is an actual binary. :D Try /bin/false20:41
ruptwelvemy bad :) I just ran exec exit 1 and got a 1 20:41
ruptwelveso I did not test it 20:41
ruptwelveunder script tho, it is still 020:42
AnrDaemonI'm very suspicious of any scripts in upstart job as of late.20:42
ruptwelveYeah, unfortunately due to the /bin/sh -e 20:42
ruptwelveif any of the commands fail, the script exits20:42
ruptwelveand it just ends there 20:43
ruptwelveno error or nothing :/ 20:43
AnrDaemonPlus you have test ${PIPESTATUS[0]} -eq 020:48
ruptwelveyeah that is just to test the output before tee 20:49
ruptwelvebut even if I have /usr/sbin/httpd -D FOREGROUND20:50
ruptwelvei still get the same result20:50
AnrDaemonhttp://pastebin.com/M6AUXFzy20:51
AnrDaemonSomething like that. (untested)20:51
AnrDaemonErr, typo in #14.20:52
ruptwelveI see :)20:54
ruptwelvethe expect for marks the service as running20:54
ruptwelveeven though it is not 20:54
AnrDaemonThat's why I said it needs testing and correct handling.20:55
AnrDaemonhttp://upstart.ubuntu.com/cookbook/#expect20:55
ruptwelveWell thank AnrDaemon, you were of assitance20:56
ruptwelveI spent the entire day googling this20:56
AnrDaemonGoogling what? :D20:56
ruptwelveupstart and exit codes :D 20:56
ruptwelveI was hoping that it would return an exit code of the script block20:56
AnrDaemonSorry, it was on my todo list to make apache2 run from upstart, but I didn't find time to actually port it.20:56
ruptwelvebut I guess it doesn't work 20:57
ruptwelveas I expected20:57
ruptwelveWell, the thing is it starts 20:57
AnrDaemonIt works but not the way you expect.20:57
ruptwelveI can have it run no problem 20:57
ruptwelveI just want to make sure it runs with error handling 20:57
AnrDaemonJust ask yourself one question: when the system is booting, where to return the exit codes?20:57
ruptwelveHmm, let me explain a bit20:57
AnrDaemonupstart is designed to do precisely that.20:57
ruptwelveI have this big wrapper application around the server(s) 20:58
ruptwelvethat restarts the apache server once you push new data to it20:58
AnrDaemonTo not just start the job, but also suprvise its execution.20:58
ruptwelvenew configs / applications / whatever 20:58
AnrDaemonThat's parallel to init daemon's job.20:58
ruptwelveand it runs service stop httpd 20:58
ruptwelvecopies new stuff 20:58
ruptwelveservice start http d20:58
AnrDaemonWell, that's the wrong way to do it…20:59
ruptwelveand from the applications perspective everything started fine 20:59
AnrDaemonYou don't need to stop httpd just to upload new data.20:59
AnrDaemonLEarn the power of atomic operations ;)20:59
ruptwelveas there is no error from initctl regarding starting apache20:59
ruptwelveah no :)20:59
ruptwelvewell I can also upload a new version of httpd.conf :)20:59
AnrDaemonWell, then you are probably better off with something like LXD or docker.21:00
ruptwelveAnd I can have a user make a mistake in the httpd.conf 21:00
ruptwelveand he wont know why apache did not start21:00
ruptwelveit will just show as started 21:00
ruptwelveright! :) You have a point, there are so many better ways to do this21:00
ruptwelvebut that is not my call ;) 21:00
ruptwelveI am just trying to find the best solution here21:00
AnrDaemonNo, if apache did not start, it will not be shown as started.21:01
ruptwelveCorrect! 21:01
AnrDaemonAlso, make pre-start script with apachectl -t21:02
ruptwelveBut the actual output of initctl start httpd will be good 21:02
ruptwelveyes I did that :)21:02
ruptwelvebut that just checks the configuration21:02
ruptwelveI would like to be more resiliant21:02
AnrDaemonWell, it have more options…21:02
ruptwelvefor example if the  socket is occupied 21:02
AnrDaemonIt is as resilient as possible.21:02
ruptwelveWish there was a dry-run option for apache :)21:02
AnrDaemonIf pre-start script fails, the job will never run in forst place.21:02
AnrDaemonfirst**21:03
AnrDaemonAnd thus you can take actions.21:03
ruptwelveThat is fine21:04
ruptwelvewhen it comes down to config21:04
ruptwelvebut is there an option to dry-run apache?21:04
ruptwelveLike a test run, to just make sure it will run - and if so, just continue with upstart21:04
AnrDaemonThat's what apachectl do. Else it wouldn't be able to test config.21:07
AnrDaemonSince module-dependent options can only be recognized by the respective modules.21:08
ruptwelvebut what happens if there a port already occupied ? 21:08
ruptwelvethat is if the socket is not available21:08
ruptwelvehmm let me test that :)21:08
AnrDaemonNothing. (If we talk about test runs.)21:08
ruptwelveoh nice21:09
ruptwelveIt actually tests that <321:09
ruptwelveTHERE IS MY SOLUTION21:09
ruptwelveYou Sir deserve a beer 21:09
AnrDaemonSure. Golden Barrel light 0.5 will suffice. In glass, please.21:10
ruptwelveI guess Golden Barrel is American? 21:10
ruptwelveRussian! 21:10
AnrDaemonhehehe21:10
AnrDaemonI guess it testing if the port is occupied by some other application?21:18
ruptwelveCorrect21:18
ruptwelveI am just trying to finish up the .conf file21:18
ruptwelveI will share once I am done :)21:18
AnrDaemonAhha. 'Cause I've tried to find a way for it to break when it is already running. With no success.21:19
AnrDaemonI've 2 weeks since I moved most of my services into containers. And there's at most 2 services running per each.21:20
AnrDaemonOk, plus Samba where it is applicable.21:20
AnrDaemon(I.e. MySQL container runs only MySQL with minimum support.)21:20

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