Of daemons and threads

by Patrick Ruckstuhl (modified: 2012 Jun 04)

As some of you might know, I'm at the moment working on my Master thesis and I'm building the core for Origo.

The last couple of days I spent trying to make my stuff into proper daemons that can run for hours and hours with lots of requests going on. After a couple of difficulties it now looks very promising. The daemons are now running for over 6 hours and have handled about 100'000 requests.

There were some things I had to do as there seem to be some problems with EiffelThreads, but in the end the changes I had to do might very well be a better design than what I had intended first. Instead of creating new threads all the time I just use a couple of worker threads that work on a common job queue. After the changes it looks great, it seems that there are no more memory leaks and as told before the daemons seem to run very fine.

Comments
  • Martin Seiler (10 years ago 3/4/2007)

    How do you turn your processes into daemons?

    Would be interesting to know.

    • Patrick Ruckstuhl (10 years ago 3/4/2007)

      That's basically not that hard. In general on Unix/Linux, the way it is done is to let the process fork itself and then end the parent process. As soon as the parent process exits, the child process is automatically inherited by the init process and can therefore be considered a daemon. In Eiffel probably the easiest way to do it, is to use eposix. Another aspect that should also be done is to implement some signal handlers (e.g. for the TERM signal, to be able to shut down a daemon), I also did this using eposix. If there's interest I can write a quick article about it.

      • Martin Seiler (10 years ago 3/4/2007)

        Eiffel and Unix

        I personally would be interested to know how to setup signal handlers in Eiffel.