Linux, Python, services and demons

0

I have a program in python that works with sockets (opens a server, collects information, filters it, etc.) and I want to launch it at the beginning of linux.

I would like to launch it as a service.

For this I have created the start script (/etc/init.d/myscript), where it responds to the commands start, stop, restart, status ... and where I have to put the link to the program that I want to launch.

And now comes the part where I'm stuck:

On the one hand the program, on the other the start script.

Would you recommend that when you launch the python program you demonize yourself?

Or instead, do a program (in c, I suppose) between the start script and the python program so that when calling it from the script, it is he who turns the python program into a daemon?

Although, until now I am able to launch the program as a service, I can not finish it. I lose your PID, and I keep the ports open.

Thank you very much.

    
asked by Shorosky 18.10.2018 в 13:03
source

1 answer

0

You could do it with contrab so you could handle the times of occurrence example

  • * / 2 * * * python /home/test/cron/example1.py
answered by 24.10.2018 в 03:52