fedora_newb | I 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/zN9fP0Gr | 05:12 |
---|---|---|
=== fedora_newb_ is now known as fedora_newb | ||
AnrDaemon | fedora_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 |
AnrDaemon | If 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 | ||
ruptwelve | Hello Upstart peoples | 19:30 |
ruptwelve | Is anyone around to assist with a question I have ? | 19:30 |
ruptwelve | Regarding script stanzas and exit codes | 19:30 |
ruptwelve | The issue I am having is parsing errors from apache startup | 19:31 |
AnrDaemon | ruptwelve: What specifically you are "parsing" ? | 20:21 |
ruptwelve | So | 20:21 |
ruptwelve | I have an upstart config | 20:21 |
ruptwelve | that runs httpd with some arguments | 20:21 |
ruptwelve | when I run initctl start httpd I get the message: httpd start/running PID xxxx | 20:22 |
AnrDaemon | Want an advice? Ditch as many "arguments" as possible. | 20:22 |
ruptwelve | Regardless if the apache server started or not | 20:22 |
ruptwelve | right | 20:22 |
ruptwelve | so event if I run just /usr/sbin/httpd | 20:22 |
AnrDaemon | Tell apache to not daemonize. | 20:22 |
ruptwelve | Should I get an exit code ? | 20:22 |
AnrDaemon | You ALWAYS get an exit code, when program exits. | 20:23 |
ruptwelve | right | 20:23 |
ruptwelve | but I always get a 0 | 20:23 |
ruptwelve | even if Apache did not start | 20:23 |
AnrDaemon | Yes. So, again. | 20:23 |
AnrDaemon | FFFFFFFFFFFFFFF | 20:24 |
AnrDaemon | 1. If you are delegating all active scripting to other daemons or running mpm-itk, tell apache to not daemonize. | 20:25 |
AnrDaemon | 2. If you are using active content filters, then see cookbook, "tracking the wrong PID". | 20:25 |
AnrDaemon | In either case, do not test it on live system. | 20:26 |
ruptwelve | This is not a live system so that is fine | 20:26 |
AnrDaemon | And always ensure that initctl status reporting "stopped". | 20:26 |
ruptwelve | what I am trying to achieve here is to be sure weather apache did start or not | 20:26 |
AnrDaemon | Before starting the job again. | 20:27 |
ruptwelve | Right | 20:27 |
AnrDaemon | upstart will manage that by itself, once you set up PID tracking correctly. | 20:27 |
AnrDaemon | I hope you do not use any wrapper scripts? | 20:27 |
ruptwelve | Allow me to paint a picture | 20:27 |
AnrDaemon | Better pastebin your job script :) | 20:28 |
ruptwelve | sure one sec | 20:28 |
AnrDaemon | That would be an image worth 1000 words. | 20:28 |
ruptwelve | so | 20:31 |
ruptwelve | http://pastebin.com/raw/CUYkRcGX | 20:31 |
ruptwelve | that is httpd.conf | 20:31 |
ruptwelve | under /etc/init/ | 20:31 |
AnrDaemon | Use exec. Not script. | 20:31 |
AnrDaemon | And use upstart to set ulimits. | 20:32 |
AnrDaemon | And other vars. | 20:32 |
ruptwelve | And this is a part of the /etc/init.d/httpd | 20:33 |
ruptwelve | http://pastebin.com/raw/ZTCBNNBu | 20:33 |
ruptwelve | Which triggers initctl | 20:33 |
AnrDaemon | If you have init/httpd.conf the init.d/httpd will only be called by idiots and degenerates. | 20:34 |
ruptwelve | well | 20:35 |
AnrDaemon | "service" wrapper will find upstart/systemd scripts before init.d | 20:35 |
ruptwelve | right | 20:35 |
ruptwelve | but even if just using initctl | 20:35 |
AnrDaemon | Just make sure you update-rc.d -f apache2 remove | 20:35 |
AnrDaemon | Ok, to reiterate: | 20:36 |
AnrDaemon | 1. You're using wrapper script. Thus making the job of finding the right PID to track unnecessarily hard. | 20:36 |
AnrDaemon | 2. You're using runlevels instead of proper signals. start on local-filesystems and net-device-up IFACE!=lo is usually sufficient. | 20:37 |
AnrDaemon | Also remove any "respawn" stanzas until your job is tracking the right pid. | 20:38 |
ruptwelve | Okay! Thank you for clearing some stuff up AnrDaemon | 20:38 |
ruptwelve | But I still don't understand why I cannot just get an exit code other than 0 from the initctl script ? | 20:39 |
ruptwelve | Even if I just run exit 1 | 20:39 |
ruptwelve | "exec exit 1" | 20:39 |
ruptwelve | if I run initctl start httpd | 20:40 |
ruptwelve | echo $? | 20:40 |
ruptwelve | I will always get 0 | 20:40 |
AnrDaemon | Because "initctl start ..." sends signal to init daemon, and if signal is sent all proper, the exit code is a success. | 20:41 |
ruptwelve | right | 20:41 |
ruptwelve | That makes sense | 20:41 |
AnrDaemon | Also I'm not sure "exit" is an actual binary. :D Try /bin/false | 20:41 |
ruptwelve | my bad :) I just ran exec exit 1 and got a 1 | 20:41 |
ruptwelve | so I did not test it | 20:41 |
ruptwelve | under script tho, it is still 0 | 20:42 |
AnrDaemon | I'm very suspicious of any scripts in upstart job as of late. | 20:42 |
ruptwelve | Yeah, unfortunately due to the /bin/sh -e | 20:42 |
ruptwelve | if any of the commands fail, the script exits | 20:42 |
ruptwelve | and it just ends there | 20:43 |
ruptwelve | no error or nothing :/ | 20:43 |
AnrDaemon | Plus you have test ${PIPESTATUS[0]} -eq 0 | 20:48 |
ruptwelve | yeah that is just to test the output before tee | 20:49 |
ruptwelve | but even if I have /usr/sbin/httpd -D FOREGROUND | 20:50 |
ruptwelve | i still get the same result | 20:50 |
AnrDaemon | http://pastebin.com/M6AUXFzy | 20:51 |
AnrDaemon | Something like that. (untested) | 20:51 |
AnrDaemon | Err, typo in #14. | 20:52 |
ruptwelve | I see :) | 20:54 |
ruptwelve | the expect for marks the service as running | 20:54 |
ruptwelve | even though it is not | 20:54 |
AnrDaemon | That's why I said it needs testing and correct handling. | 20:55 |
AnrDaemon | http://upstart.ubuntu.com/cookbook/#expect | 20:55 |
ruptwelve | Well thank AnrDaemon, you were of assitance | 20:56 |
ruptwelve | I spent the entire day googling this | 20:56 |
AnrDaemon | Googling what? :D | 20:56 |
ruptwelve | upstart and exit codes :D | 20:56 |
ruptwelve | I was hoping that it would return an exit code of the script block | 20:56 |
AnrDaemon | Sorry, it was on my todo list to make apache2 run from upstart, but I didn't find time to actually port it. | 20:56 |
ruptwelve | but I guess it doesn't work | 20:57 |
ruptwelve | as I expected | 20:57 |
ruptwelve | Well, the thing is it starts | 20:57 |
AnrDaemon | It works but not the way you expect. | 20:57 |
ruptwelve | I can have it run no problem | 20:57 |
ruptwelve | I just want to make sure it runs with error handling | 20:57 |
AnrDaemon | Just ask yourself one question: when the system is booting, where to return the exit codes? | 20:57 |
ruptwelve | Hmm, let me explain a bit | 20:57 |
AnrDaemon | upstart is designed to do precisely that. | 20:57 |
ruptwelve | I have this big wrapper application around the server(s) | 20:58 |
ruptwelve | that restarts the apache server once you push new data to it | 20:58 |
AnrDaemon | To not just start the job, but also suprvise its execution. | 20:58 |
ruptwelve | new configs / applications / whatever | 20:58 |
AnrDaemon | That's parallel to init daemon's job. | 20:58 |
ruptwelve | and it runs service stop httpd | 20:58 |
ruptwelve | copies new stuff | 20:58 |
ruptwelve | service start http d | 20:58 |
AnrDaemon | Well, that's the wrong way to do it… | 20:59 |
ruptwelve | and from the applications perspective everything started fine | 20:59 |
AnrDaemon | You don't need to stop httpd just to upload new data. | 20:59 |
AnrDaemon | LEarn the power of atomic operations ;) | 20:59 |
ruptwelve | as there is no error from initctl regarding starting apache | 20:59 |
ruptwelve | ah no :) | 20:59 |
ruptwelve | well I can also upload a new version of httpd.conf :) | 20:59 |
AnrDaemon | Well, then you are probably better off with something like LXD or docker. | 21:00 |
ruptwelve | And I can have a user make a mistake in the httpd.conf | 21:00 |
ruptwelve | and he wont know why apache did not start | 21:00 |
ruptwelve | it will just show as started | 21:00 |
ruptwelve | right! :) You have a point, there are so many better ways to do this | 21:00 |
ruptwelve | but that is not my call ;) | 21:00 |
ruptwelve | I am just trying to find the best solution here | 21:00 |
AnrDaemon | No, if apache did not start, it will not be shown as started. | 21:01 |
ruptwelve | Correct! | 21:01 |
AnrDaemon | Also, make pre-start script with apachectl -t | 21:02 |
ruptwelve | But the actual output of initctl start httpd will be good | 21:02 |
ruptwelve | yes I did that :) | 21:02 |
ruptwelve | but that just checks the configuration | 21:02 |
ruptwelve | I would like to be more resiliant | 21:02 |
AnrDaemon | Well, it have more options… | 21:02 |
ruptwelve | for example if the socket is occupied | 21:02 |
AnrDaemon | It is as resilient as possible. | 21:02 |
ruptwelve | Wish there was a dry-run option for apache :) | 21:02 |
AnrDaemon | If pre-start script fails, the job will never run in forst place. | 21:02 |
AnrDaemon | first** | 21:03 |
AnrDaemon | And thus you can take actions. | 21:03 |
ruptwelve | That is fine | 21:04 |
ruptwelve | when it comes down to config | 21:04 |
ruptwelve | but is there an option to dry-run apache? | 21:04 |
ruptwelve | Like a test run, to just make sure it will run - and if so, just continue with upstart | 21:04 |
AnrDaemon | That's what apachectl do. Else it wouldn't be able to test config. | 21:07 |
AnrDaemon | Since module-dependent options can only be recognized by the respective modules. | 21:08 |
ruptwelve | but what happens if there a port already occupied ? | 21:08 |
ruptwelve | that is if the socket is not available | 21:08 |
ruptwelve | hmm let me test that :) | 21:08 |
AnrDaemon | Nothing. (If we talk about test runs.) | 21:08 |
ruptwelve | oh nice | 21:09 |
ruptwelve | It actually tests that <3 | 21:09 |
ruptwelve | THERE IS MY SOLUTION | 21:09 |
ruptwelve | You Sir deserve a beer | 21:09 |
AnrDaemon | Sure. Golden Barrel light 0.5 will suffice. In glass, please. | 21:10 |
ruptwelve | I guess Golden Barrel is American? | 21:10 |
ruptwelve | Russian! | 21:10 |
AnrDaemon | hehehe | 21:10 |
AnrDaemon | I guess it testing if the port is occupied by some other application? | 21:18 |
ruptwelve | Correct | 21:18 |
ruptwelve | I am just trying to finish up the .conf file | 21:18 |
ruptwelve | I will share once I am done :) | 21:18 |
AnrDaemon | Ahha. 'Cause I've tried to find a way for it to break when it is already running. With no success. | 21:19 |
AnrDaemon | I've 2 weeks since I moved most of my services into containers. And there's at most 2 services running per each. | 21:20 |
AnrDaemon | Ok, 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!