in reply to How to fork multiple processes in a daemon
I am not sure of how to implement above logic. All I know is how to create a basic daemon
Are you unsure of just how to handle the daemon after creation or do you also need help with its various tasks, as well?
If you are still learning how to do each of these tasks, , I would suggest that you start by writing working code that does each of the subtasks. Even if you are familiar with the pieces, I'm not convinced "create a daemon" is your first step.
Daemons can be tricky to debug, so making sure the tasks done by the daemon work on their own is important. Adding parallel processes forked off of a main process only increases the complexity. Only when you are sure that you know how to write working code for each task, only then combine it all into one working script that forks off processes and sends then.
Having working code for each of the subtasks will also give you a better idea of exactly what data needs to go in and out of each subtask. That will make it easier to assemble the pieces, using a tool like Parallel::ForkManager or POE.
Even when you are ready to assemble the pieces, you should write your program so that it can be run in non-daemon mode first. Make sure it works when you trigger it manually. Then work on the wrapper code to install it as a daemon. There are a lot of things that can go wrong with daemons (permissions, for example). Unless you have previously debugged your code in non-daemon mode, it can be difficult to tell which things are due to broken code and which are due to the interaction with the environment.
Best, beth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to fork multiple processes in a daemon
by piyush (Novice) on Sep 18, 2009 at 12:32 UTC |