A
A
Artem Prokhorov2021-12-02 22:14:25
go
Artem Prokhorov, 2021-12-02 22:14:25

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

2 answer(s)
U
uvelichitel, 2021-12-03
@kotcich

"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.goor 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 &

A
Alexander Karabanov, 2021-12-02
@karabanov

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 question

Ask a Question

731 491 924 answers to any question