I want to run my Go program forever like pm2 for nodejs.
A quick web search yields these results as the first four hits:
[OT] Forever? I don’t think you will find that level of guarantee with any solution you find on the internet, forever is a very long time, you know? [/OT]
I don’t know what pm2 is, but it boils down to learning about the targets distribution init system or windows services and deploy your program in a way that it’s at least compatible with them, perhaps even provide necessary unit/service files.
So i will change my question how to exit linux Terminal without closing Go program?
This not not related to Go … but
I’ll check them out, thanks.
I´ll check, thanks.
You use the capabilities of your init system. The most prominent today is probably systemd, but which exactly is used on your system, I don’t know as you haven’t told which Linux you use.
Hey i use ubuntu 18 and centos 7
Both are on
systemd iirc, I’m pretty sure about CentOS, though Ubuntu switched the init system a couple of times over the last 10 years, so you have to check there individually.
Alright ill check it out thanks men.
on linux you can use screen but when your system is turned off these screens are gone in other words program stops and other option is creating services by using following code
[Unit] Description=Service description Requires=network.target [Service] User=root Restart=on-failure ExecStart=/usr/bin/NAMEOFFILE [Install] WantedBy=multi-user.target
every time you do an update to your code just replace build with newer one at this path
and run following command
sudo service NAMEOFSERVICE restart
thanks ill check it out.
I actually use pm2 to keep my go binary services running, logs and monitoring
Like this, (pm2 start main.exe) ?
Are you looking for systemd and/or supervisor? Just guessing here…
Well there you have it
Yeah I just did ir jajaj thanks