I currently have a Makefile rule thus:
start:
./start.sh
which starts a very simple server needed as part of the build process. I have another rule for stopping the server:
stop:
kill `cat bin/server.PID`
here is the start.sh script:
#!/bin/bash
cd bin
python server.py &
echo $! > server.PID
NB server.py must be run from within the bin directory
I'd like to implement the functionality of start.sh within the start rule, I've tried numerous things but can't seem to get the PID.
I don't understand where you're getting stuck. What's wrong with
start:
cd bin && { python server.py & echo $$! > server.PID; }
?
You can also make the pidfile a target and dependency:
start: server.PID
server.PID:
cd bin && { python server.py & echo $$! > $@; }
stop: server.PID
kill `cat $<` && rm $<
.PHONY: start stop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With