1

Should a daemon, forked from a CGI script (whenever the CGI script is called and the daemon is not yet running), hang running (most of the time just waiting for a connection) all time, or should it be terminated as soon as there is no more data to process (to be restarted by the next CGI call)? (The process is a Perl script.)

This happens on FreeBSD.

The details of what I am going to implement are available at Writing a daemon behind CGI: WebSocket or long polling question.

porton
  • 791

1 Answers1

1

It looks like your situation is a good candidate for (at least) FastCGI, or perhaps making some dedicated HTTP server (perhaps using some HTTP server library like libonion) that your main web server would use as "proxy" for some selected requests or URLs.

There is also the issue about what kind of state should the daemon keep from one CGI request to the next one.

Intuitively, you could use as criteria to stop your daemon after a few minutes (real-time) of inactivity.

(You definitely should give more details and motivations)