Re: [go-nuts] Architect a daemon program
On 11/10/16 18:09, Tong Sun wrote: > I've searched the mlist archive and have learned that I should > avoid daemonize as much as possible. So instead of label my program as a > daemon (or singleton or anything), let me describe what I need to do. > > I need the program (say, named as`myprog`) to fork into the background > (if possible) with the "start" command-line option. You could try this https://github.com/sevlyar/go-daemon This implements the daemonization by re-running the executable with an environment variable. -- Nick Craig-Wood-- http://www.craig-wood.com/nick -- 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.
Re: [go-nuts] Architect a daemon program
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.
[go-nuts] Architect a daemon program
I've searched the mlist archive and have learned that I should avoid daemonize as much as possible. So instead of label my program as a daemon (or singleton or anything), let me describe what I need to do. 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? Thanks -- 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.