On 2016-10-11 19:09, Tong Sun wrote:
I need the program (say, named as`myprog`) to fork into the background (if possible) with the "start" command-line option. What's important is that when `myprog` is called with other command-line options, it will /communicate with the running background process/. To make it very simple, myprog will keep an internal counter that increases every second, - when `myprog status` is called, the internal counter's value is printed. - when `myprog restart` is called, the internal counter's value is reset to zero. - when `myprog stop` is called, the background process is terminated. What's the simplest way to write such simple program in Go?
I would not fork, but keep the program in the foreground, - then run the program under a daemon supervisor - like "runit" or "systemd".
... and the way the cmd line invocation communicate with the running daemon can be many. signal, sockets, dbus...
/Peter -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.