Supervisord requires that the programs it is configured to run don’t daemonize themselves. Instead, they should run in the foreground and respond to the stop signal (TERM by default) by properly shutting down.

Use Following shell script to wrapper your background program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# run something background
./run &
# get nearest running background pid
$PID=$!
# Perform program exit housekeeping
function clean_up {
# dosomething for cleanup
rm -rf dump_file
# remove trap
trap - SIGHUP SIGINT SIGTERM SIGQUIT SIGKILL
exit $?
}
# Add trap for catch sistem signal
trap clean_up SIGHUP SIGINT SIGTERM SIGQUIT SIGKILL
wait $PID

Comment and share

  • page 1 of 1

Cwza

Hello everyone.
I’m cwza.
Welcome to my blog.


Software Engineer


Taiwan/Taipei