Para ejecutar el servidor web nodejs para siempre, puede usar forever como:
1 | forever start index.js |
¿Cómo hacer esto con Python?
Hay muchos métodos, puedo mostrar uno de ellos:
Paso 1:
1 | vi /etc/systemd/system/my-python-daemon.service |
contenido:
1 2 3 4 5 6 7 8 9 10 11 12 13 | [Unit] Description=My Python App [Service] Type=simple WorkingDirectory=/root/photoshop/BASNet-http ExecStart=/usr/bin/python3 main.py Restart=always # Restart service after 10 seconds if python service crashes RestartSec=10 [Install] WantedBy=multi-user.target |
Paso 2:
1 2 | systemctl enable my-python-daemon systemctl start my-python-daemon |
Resultado:
1 2 3 | [root@tutorialspots ~]# systemctl enable my-python-daemon Created symlink from /etc/systemd/system/multi-user.target.wants/my-python-daemon.service to /etc/systemd/system/my-python-daemon.service. [root@tutorialspots ~]# systemctl start my-python-daemon |
0 Comentarios
Dejanos tu comentario para seguir mejorando!