I'm using capistrano to deploy a python service. I was trying to both start the service and also write a pidfile, so I can restart the service or stop the service later. The problem is the pidfile is always one process ID behind, and I'm not sure why. For example, if the pidfile says 123, then the actually running process is 124. Should I manually add one? Or am I writing the command wrong? I'll write the psuedo command here:
nohup python ./service.py special_argument --config /some_folder/devel.yml --log logs/service.log > /dev/null 2>&1& echo $! > /some_folder/pids/special_argument.pidfile