Little systemd script, to autostart your app on failures and server reboots.
[Unit]
Description=YOUR_APP_DESCRIPTION
After=network.target
[Service]
User=YOUR_DEPLOY_USER
Group=YOUR_DEPLOY_USER
Restart=on-failure
Environment=PORT=YOUR_DEPLOY_PORT
Environment=HOME=/home/DEPLOY_USER/APP_NAME
ExecStart= /home/DEPLOY_USER/APP_NAME/bin/APP_NAME foreground
ExecStop= /home/DEPLOY_USER/APP_NAME/bin/APP_NAME stop
[Install]
WantedBy=multi-user.target
Save file as YOUR_APP_NAME.service and reload systemctl daemon
sudo systemctl enable YOUR_APP_NAME.service
sudo systemctl daemon-reload
That’s it :)