I have a Makefile that runs a Django web server. I would like the server to start in the background, with the PID being saved in a file.
My recipe is as follows:
run: venv @"${PYTHON}" "${APP}/manage.py" runserver 80
Intuitively, in order to execute the background process and capture the PID, I would need to do something like this:
run: venv @"${PYTHON}" "${APP}/manage.py" runserver 80 & ; echo "$$!" > "${LOGDIR}/django.pid"
This does not work. A sub-shell that uses "make" (/ bin / sh in my case) works when you use:
<command> &
... execute the background process and work when using:
<command> ; <command>
(or <command> && <command>
etc.) for chaining commands. However, when I try to execute the first process and connect the second, I get the following error:
/bin/sh: -c: line 0: syntax error near unexpected token `;'
What is the best way to background process and capture PID in Makefile?
thanks
- B
source share