:: Re: [DNG] libnetaid-0.1
Página Inicial
Delete this message
Reply to this message
Autor: Steve Litt
Data:  
Para: dng
Assunto: Re: [DNG] libnetaid-0.1
On Fri, 21 Aug 2020 00:56:37 +0200
aitor <aitor_czr@???> wrote:

> Hi Steve,
>
> On 17/8/20 12:53, Steve Litt wrote:
> > Hi Aitor,
> >
> > It's very important that there continue to be a way to run
> > simple-netaid in the foreground, so runit and s6 and other good
> > inits can run it reliably, without kludge.
> >
> > I can see by your code that your intent was to give the user a
> > choice of self-daemonize or foreground, judging by the lines:
> >
> > 46: static int daemonized_flag = 1;
> > and
> > 585: if (daemonized_flag == 1) {
> >
> > but I saw no way for the user to set daemonized_flag to 0. I saw a
> > way for the user to reiterate setting it to 1:
> >
> > 484: {"daemon",               no_argument,  &daemonized_flag, 1},

> >
> > If I remember my getopt_long correctly, the preceding line allows
> > someone to specify --daemon but not whether it's 1 or 0, and the
> > preceding line defaults it to 1.
>
> You are right, there was no way to set this flag to zero.
>
> I've just started making the changes needed (still not tested) and,
> in the meantime,
> i'm also improving the documentation in the Readme files, focusing
> the tutorials to
> other distributions using different package management systems.
>
> For example, you can look at the howto of libnetaid:
>
> https://git.devuan.org/aitor_czr/libnetaid
>
>
> > I'd suggest you add -f and --foreground so the user can set it to
> > foreground.
>
> You are suggesting something like:
>
> # snetaid          (run in the background - *Default*)
>
> # snetaid  -f      (run in the foreground)
>
> > Personally, I'd also suggest setting the default to foreground, to
> > better fit with inits like runit and s6, which I think some time in
> > the future will be Devuan's default init system.
> Then, in the other way around we should change the name of the flag
> to " --background "
> or  " --no-foreground ", that is:
>
> # snetaid                  (run in the foreground - *Default*)
>
> # snetaid  --background          (run in the background)


Personally, I'm a fan of having explicit options for each option, and
just do something consistent if the user uses both options. I think you
should have both --foreground and --background (or --daemon or
--daemonize). This protects the user from any future change in default.

But that's just a luxury: The main thing is to have the ability to go
either background or foreground, one way or another.

By the way, some misguided "daemons" give the ability to run in
foreground, but only via the --debug option, which also puts all sorts
of basura into the logs or /dev/null or the screen or wherever. I'm a
big proponent of having --debug be completely separate from whether the
daemon is running in the background or foreground.

By the way, I really like your code. It's easy to read, and makes
sense. If everyone coded like you, "use the source" would be a
legitimate answer to someone asking for information.

SteveT

Steve Litt
Autumn 2020 featured book: Thriving in Tough Times
http://www.troubleshooters.com/thrive