What is the simplest way to run a go server in the background? I currently have the server running in CMD and would rather not change the actual code.
Asked
Active
Viewed 326 times
1 Answers
0
I'd use a screen. Assuming Ubuntu 18.04:
sudo apt-get install screen
Then
screen
Then
go run main.go
Use Ctrl + A + D to get out of the screen. To return to it:
screen -r

Ori Almog
- 59
- 4
-
If using a Linux based system `systemd-run` can start transient units: `systemd-run --user go run main.go`. But I suppose he uses Windows (`CMD`) – Jürgen Hötzel Jun 21 '18 at 16:19
-
I'm using Windows, unfortunately – Yarden Laifenfeld Jun 21 '18 at 23:04