Skip to content

Commit b07a053

Browse files
committed
feat(controller): print stack trace when worker is killed
1 parent 3a69974 commit b07a053

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

controller/bin/boot

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ sudo -E -u deis ./manage.py syncdb --migrate --noinput
7373
# spawn a gunicorn server in the background
7474
sudo -E -u deis gunicorn -c deis/gconf.py deis.wsgi &
7575

76-
# smart shutdown on SIGINT and SIGTERM
76+
# smart shutdown on SIGTERM (SIGINT is handled by gunicorn)
7777
function on_exit() {
7878
GUNICORN_PID=$(cat /tmp/gunicorn.pid)
7979
kill -TERM $GUNICORN_PID 2>/dev/null
8080
wait $GUNICORN_PID 2>/dev/null
8181
exit 0
8282
}
83-
trap on_exit INT TERM
83+
trap on_exit TERM
8484

8585
# spawn confd in the background to update services based on etcd changes
8686
confd -node $ETCD -config-file /app/confd.toml &

controller/deis/gconf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,17 @@
77
errorlog = '-'
88
accesslog = '-'
99
access_log_format = '%(h)s "%(r)s" %(s)s %(b)s "%(a)s"'
10+
11+
12+
def worker_int(worker):
13+
"""Print a stack trace when a worker receives a SIGINT or SIGQUIT signal."""
14+
worker.log.warning('worker terminated')
15+
import traceback
16+
traceback.print_stack()
17+
18+
19+
def worker_abort(worker):
20+
"""Print a stack trace when a worker receives a SIGABRT signal, generally on timeout."""
21+
worker.log.warning('worker aborted')
22+
import traceback
23+
traceback.print_stack()

0 commit comments

Comments
 (0)