In Python Twisted, you have the twistd
command that helps you with a number of things related to running your application (daemonize it for example).
Ho
To start a systemd
service manager daemon, write a service file. For example, create a file /etc/systemd/system/myservice.service
.
[Unit]
Description=myservice-description
After=network.target
[Service]
ExecStart=/opt/myservice-location/src/node/server.js --args=here
Restart=always
User=me
Group=group
Environment=PATH=/usr/bin:/usr/local/bin
Environment=NODE_ENV=production
WorkingDirectory=/opt/myservice-location
[Install]
WantedBy=multi-user.target
Remember to update the service manager daemon after every change to the myservice.service file.
$ systemctl daemon-reload
Then start the service running and enable the service to start at boot.
$ systemctl start myservice
$ systemctl enable myservice