Answer the question
In order to leave comments, you need to log in
How to run go run main.go on ubuntu restart?
So that the server starts immediately when the system is turned on.
Answer the question
In order to leave comments, you need to log in
"So that the server starts immediately when the system is turned on" you do not need to execute go run main.go
. go run
-- this is a test compilation and run when sketching. You need to make a normal binary of your server go build -o myserver main.go
or go install
. The resulting binary can be run at system startup using standard means - the systemd unit, cron entry, or, at its simplest, by placing the command in profile
myserver &
Write a systemd unit
Another option to run in a Docker container is the easiest.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question