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


In reply to Re: How to fork multiple processes in a daemon by ELISHEVA
in thread How to fork multiple processes in a daemon by piyush

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.