To run nodejs webserver forever, you can use forever like:
forever start index.js
How to do this with golang ?
There are many methods, i can show one of them:
Step 1:
vi /etc/systemd/system/my-go-daemon.service
content:
[Unit] Description=My Go App [Service] Type=simple WorkingDirectory=/home/go ExecStart=/usr/local/go/bin/go run src/test1/main.go Restart=always # Restart service after 10 seconds if golang service crashes RestartSec=10 [Install] WantedBy=multi-user.target
Step 2:
systemctl enable my-go-daemon systemctl start my-go-daemon
1 Comment
How to run golang web server forever on Linux – Method 2 | Free Online Tutorials
(July 18, 2020 - 5:52 am)[…] this article (How to run golang web server forever on Linux) we know an old method to run golang web server forever on Linux. Now we have a new method to do […]