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.

7
  • Do you have any criteria for evaluating your decision? Are you running out of memory, for example? – Robert Harvey Jul 14 '16 at 13:33
  • @RobertHarvey No, I asked for such a criteria. I think our server has plenty of memory – porton Jul 14 '16 at 13:36
  • 1
    I edited the title of your post to more correctly reflect the question that I think you're asking. Feel free to re-edit or roll back if that's not your actual question. – Robert Harvey Jul 14 '16 at 13:38
  • 1
    Please improve your question by explaining what your CGI is doing, and what is the daemon doing. Give some motivation and context (so edit your question) – Basile Starynkevitch Jul 14 '16 at 16:55
  • @BasileStarynkevitch Done – porton Jul 14 '16 at 18:36
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)

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.