How to run golang web server forever on Linux


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

[Install]
WantedBy=multi-user.target

Step 2:

systemctl enable my-go-daemon
systemctl start my-go-daemon

Related Post

,

No comments yet.

Leave a Reply