[go] How I can build service (daemon) on go

Immediately I apologize if something is not correctly stated in the title of the topic.
the essence is …

When I run the application on the server (ubuntu, debian…etc) … I open the command line and enter the command ./app and my application works when I close the command line - it close …

How to make my program work even then when I close command line or leave the server

Wrong way: start it in a screen or tmux session and detach it.

Proper way: Use your servers service manager as eg systemd and write a service definition it understands for your program.

This is not related to go, but to your actual system.


For deploying Go programs on Unix/Linux i use a special created tool, part of my toolbox, which also have run and detach. The documentation is here.

1 Like

Thanks, After I run the ‘run’ in the toolbox, will my application do the work if I am not on the server at this time?

You can deploy remote, so is no need to be on the remote machine (in fact this is the idea). You can work and test on your Unix/Linux machine and deploy on the destination machine. Read the documentation to see how.

1 Like

thanks I try it

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.