1

I would like to start a web server on-demand as an inetd "tcp/wait" service which shuts itself down after a programmable period of inactivity.

Many web servers already support inetd "tcp/nowait" mode, but this mode has the disadvantage that a new process needs to be forked for every new connection. It is therefore slower and more resource-intensive than running a dedicated server daemon.

A web server supporting inetd's "tcp/wait" would only be launched by inetd for the first request, then serve any number of requests using the same server instance until no requests occurred for some period of idle time, in which case the server instance automatically terminates and lets inetd start it again once the next period of activity starts.

Such a tcp/wait inetd web server should have approximately the same efficiency as a dedicated web server (i. e. running permanently) during times of activity. However, it will automatically shut down in times of inactivity, saving system resources.

Irregular "anti-demand"-driven shutdowns will also clean up any memory leaks from the web server and possibly associated FGCI-services (which would terminate together with the web server).

I know that it is already possible to use systemd's socket activation in combination with lighttpd's -i option to implement what I want.

However, I want a solution that also works without systemd, depending on nothing else than a running Internet superserver no matter how the latter one has been started (inetd/xinetd started by sysvinit, runit, manually, or systemd's socket activation replacing inetd/xinetd).

  • check [immortal](https://immortal.run) https://immortal.run/post/nginx/ – nbari Oct 07 '17 at 13:54
  • @nbari As far as I can see "immortal" is a replacement for inetd, and not a way to run a web server efficiently *with* inetd. Thanks anyway, I did not know "immortal" before. I will check it out. If it should turn out to be as lightweight as inetd, I might indeed replace inetd by it and then use nginix as you suggested. – Guenther Brunthaler Oct 12 '17 at 12:30
  • @bari After a first glance at "immortal", I doubt it can help solve my problem. It does not seem to have any kind of socket activation, so how could it replace inetd? "immortal" seems to be just another variant of "runit", with the major difference that it uses yaml files rather than shell scripts for configuration, and also allows to define service dependencies in those yaml files. But like "runit", "immortal" seems to be a system for monitoring permanently running services, and offers no special functionality for on-demand starting of services. – Guenther Brunthaler Oct 12 '17 at 12:45
  • true, I just mention it because if desired you could control your process remotely via socket (web) but I think I miss understood your question. – nbari Oct 12 '17 at 13:30

0 Answers0