'Discovering information about a Python Script Launched as a Service on Red Hat Linux
I have a client who has an existing Red Hat Linux server setup on Amazon Web Services (AWS) where the important Python server code is launched as a service using sudo service bigserver2 start. When I try and run the bigserver2.py Python script independently, there are a number of runtime issues for paths and files not found. How can I backtrack through the service system and understand what environment the service is running in so I can replicate and debug some issues.
I can see the bigserver2 service running when I run sudo service --status-all and it looks like they are initiating a command with some paths added, but I don't know where my predecessor (now gone and unavailable) set things up or what else may impact the environment.
root 14207 1 0 20:15 ? 00:00:00 sudo -u webuser LD_LIBRARY_PATH=/opt/webusershared/python/ext PYTHONPATH=/opt/webusershared/python/ext/ /usr/bin/python3.6 /opt/webusershared/bigserver2.py
Solution 1:[1]
Since you are using service command instead of systemctl, I am guessing you are on REHL 6 (consider upgrading).
/etc/init.d/
Check this path, you will find a file with a name starting with "bigserver2".
Solution 2:[2]
Assuming systemd, go look in /lib/systemd/system and /etc/systemd/system for a file that matches the service name. Open that up and see what it's doing. That's likely what the system is using to launch that service.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kashish Bhatia |
| Solution 2 | pheonix991 |
