Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wrote this small shell script to start a gunicorn WSGI server for my django app. I'm running it on Ubuntu 12.04, and the script starts cleanly and runs like it's supposed to. The problem is that the script and gunicorn continues to run even after ctrl -C, i.e. it doesn't return to the prompt.

Why would this be, and how can I fix it?

Script:

#!/bin/bash
NUM_WORKERS=3
cd /path/to/my/project
source ../bin/activate

gunicorn_django -w $NUM_WORKERS
share|improve this question
    
Same problem: Can't terminate gunicorn_django via Ctrl-C when invoked from a makefile. My guess: Aborting on Ctrl-C is entirely optional. Since the the behavior is inconsistent, it's probably a bug. –  Dennis May 24 '12 at 18:31
    
Duplicate of stackoverflow.com/q/7959977/114147. Please try and do a search next time :-) –  invert May 25 '12 at 11:12
    
@wez That's really not a good solution to this question. I've submitted it to gunicorn's github and they've submitted a bug fix. I'll test it out soon and see if it fixes anything. –  HighLife May 25 '12 at 15:53

2 Answers 2

The normal way to start server processes is to have them run in the background. E.g.

gunicorn_django -w $NUM_WORKERS &

The usual way to stop servers is to send them a signal, often the server process or the script that starts it, saves it's process-ID into a file so that your stop script can do something like

kill pid

See typical examples in /etc/initd.d scripts.

share|improve this answer
    
I also tried starting/stopping this script with upstart. gunicorn_django won't stop cleanly there either. –  HighLife May 24 '12 at 18:41
    
killall gunicorn ? –  RedGrittyBrick May 24 '12 at 18:51

Here is the bug fix. After doing a clean install with that branch it seems to work fine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.