Problem with a Golang webapp and system service

Hello I am trying to create a golang server using a service on ububtu 18.04 the problem is with my app(,

root@tes-server:~/victoryDash# ./webapp
2020/06/16 09:16:15 The server is lisening on 3000 port

it works fine when it is executed in the terminal, but it does not go through the service I create this service in /lib/systemd/system/goweb.service




I have this error

root@tes-server:/lib/systemd/system# systemctl status gotest
● gotest.service - goweb
   Loaded: loaded (/lib/systemd/system/gotest.service; disabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2020-06-16 11:21:16 UTC; 2s ago
  Process: 23262 ExecStart=/root/testing2/app (code=exited, status=2)
 Main PID: 23262 (code=exited, status=2)

Jun 16 11:21:16 tes-server systemd[1]: gotest.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Jun 16 11:21:16 tes-server systemd[1]: gotest.service: Failed with result 'exit-code'.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


I faced a similar issue. So I built the app and tried running from a different directory. And I found out the issue I had was I passed in the relative path (instead of the absolute path) to my env file in a function.

You might not have the same error. I think you can try similar process to see what the error is.