/srv/irclogs.ubuntu.com/2012/10/18/#upstart.txt

lurch_hi, having an issue with stopping a service through upstart on ubuntu. The app is a very basic sinatra server that listens on some port. Starting goes fine, i can access the service, but there's a problem with restarting/stopping the service. One process stays running, which keeps the  port in use. Here's the output i get for the commands: http://pastebin.com/k9hdNJLE07:35
jodhlurch_: you've probably mis-specified (or not specified) the 'expect' stanza: http://upstart.ubuntu.com/cookbook/#expect07:41
lurch_jodh: thx. let me look at that07:43
jodhlurch_: after starting your job, try running 'status app01' and checking that the pid shown is correct (confirm it using 'ps'). If not, it's an expect issue.07:44
lurch_jodh: the status command isn't showing any pids07:50
lurch_# status app0107:50
lurch_app01 start/running07:50
jodhlurch_: right, so I suspect your daemon forks either once or twice, but you haven't added an 'expect' to allow Upstart to track the forks.07:52
lurch_thx. added an 'expect fork' now, testing07:52
lurch_added the 'expect fork' (and also tried 'expect daemon'), but then the start / stop just hangs. Must be doing something stupid, but not that familiar with upstart. Here's the config: http://pastebin.com/RuUwyn8A07:58
lurch_the upstart scripts are generated by 'foreman'08:00
jodhlurch_: don't add respawn until you are 100% convinced that you've got the rest of the config correct as it will just cause confusion.08:00
lurch_ok08:00
jodhlurch_: also, you can simplify that exec line by doing 'setuid app' and 'chdir /opt/apps/app01'. Note too that you may be able to get rid of all that redirection since Upstart will automatically log all output to stdout/stderr to /var/log/upstart/app01.log.08:03
jodhlurch_: Um. where is $PORT being defined? I suspect that might be the cause of your problem.08:04
jodhlurch_: either set it via 'env PORT=1234' or pass in via command line 'start app01 PORT=1234' or source your apps config file as shown here: http://upstart.ubuntu.com/cookbook/#sourcing-files08:05
lurch_jodh: ok, i'll try that. thx08:06
aaronlevyI'm having trouble with restarts of a python process that spawns other worker processes.20:23
aaronlevyThe process cant have 2 instances of itself running because a socket will already be in use by the other process. What seems to be happening is that upstart is re-starting the process before it has actually stopped the original (the parent will not exit until all children have completed their work). 20:24
aaronlevyUsing start/stop works fine. Restart, however, will periodically cause the above to happen and then the process never exits, but upstart reports that is is not running20:25
ionAdd something like kill timeout 30020:26
ionOr whatever number makes sense.20:26
aaronlevyHmm. I mean, shouldn't it track the PID of the parent process?20:27
ionyes20:28
ionBut it sends SIGKILL if it doesn’t terminate in a certain number of seconds after SIGTERM.20:28
aaronlevyThen just assumes it is closed?20:28
ionSIGKILL kills it for good, so the process won’t exist anymore.20:29
aaronlevyHmm.. but the process is still there (as are the children). 20:29
ionYou can also add a pre-stop exec/script if the server provides a command that tells it to stop and waits until it does.20:29
ionhuh20:29
aaronlevyno re respawns either. Let me double check that it is the same as originating pid20:30
aaronlevySo the zombie process is not the same PID as what restart reports20:33
aaronlevyI made a stub of my actual program that re-creates the issue. https://gist.github.com/7cf1c9ef87a50ef08c9c (requires pyzmq)21:25
aaronlevyand upstart conf: https://gist.github.com/ecc65af894d72c91cecb21:25
aaronlevyrepeatedly restarting the service quickly will cause it to get an error because the socket is still in use. Upstart will report the process as stopped, but there will be a zombie process (doing nothing)21:26
aaronlevyThis is probably a mistake on my part, but I'm not sure where :/21:27

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