I've written a small python script to act as a LSB compliant init script for an Apache Tomcat service. I've done this script and initial tests on my work laptop which runs openSUSE; The actual deployment is to be made on Ubuntu Server (no jokes about it please, I also feel sad about it).
While the script works perfectly under openSUSE (python 2.7.3), in Ubuntu it's behavior is different (also python 2.7.3)...
When I perform the subprocess.Popen call, in openSUSE it opens the process and then I capture the .pid to a 'control' file...
In Ubuntu, the very same script, the subprocess.Popen call opens two process, one starting with '/usr/bin -c java (...)' and then another 'java (...)'. This is really annoying has the PID written is the one from the /bin/sh...
This is my first time working with Ubuntu Server and though I'm already planning to migrate everything to RHEL (where this non-sense doesn't happen also), I'm still interested in knowing why this happens in Ubuntu and potential ways to dodge around it...
The start function is this one
def start():
set_user()
with open(CATALINA_OUT, "a") as log:
tomcat = subprocess.Popen(TOMCAT_CMD + 'start', shell=True, stdout=log, stderr=log)
write_pidfile(tomcat.pid)
def set_user():
os.setgid(int(TOMCAT_GID))
os.setuid(int(TOMCAT_UID))