-
Download and install Go, if necessary:
-
Using the go build
command, compile your Go application to an executable file. Ensure that the executable work properly when you run it from a command prompt.
We'll work with a small Go web server application called simple-server in this tutorial.
As you can see, we were able to compile and launch our package/program successfully:
-
Download and install AlwaysUp, if necessary.
-
Start AlwaysUp.
-
Select Application > Add to open the Add Application window:
-
On the General tab:
-
In the Application field, enter the full path to your complied Go executable.
-
In the Start the application field, select Automatically, but shortly after the computer boots.
With this setting, your Go application will start 1-2 minutes after a reboot — after critical windows services
(such as networking and domain authentication) have fully initialized and are ready to go.
-
In the Name field, enter the name that you will call the application in AlwaysUp.
We have stuck with the default of Go Server but you can specify another name if you like.
-
We are now done configuring your Go application to run as a service so click the Save button to record your settings.
After a couple of seconds, a new entry called Go Server (or whatever you called it) will appear in the AlwaysUp window.
The state will be "Stopped" because your application hasn't started yet:
-
To start your Go application from AlwaysUp, choose Application > Start "Go Server".
The state will transition to "Running":
-
And finally, confirm that your Go application is functioning as expected.
For example, is it available at the expect URL in your browser?
Is it writing log files, or communicating with the database?
Everything should be humming along when you're running as a Windows Service.
-
That's it! Next time your computer boots, your Go application will start automatically, before anyone logs on.
We encourage you to edit your entry in AlwaysUp and check out the many other settings that may be appropriate for your environment.
For example, send email when Go crashes or stops for any reason, run in a specific user account (for proper permissions),
automatically restart the program nightly to cure memory leaks, and much more.