Making a Perl daemon that runs 24/7 and reads from named pipes

后端 未结 2 1134
梦谈多话
梦谈多话 2021-02-15 13:20

I\'m trying to make a log analyser using perl. The analyser would run 24/7 in the background on an AIX server and read from pipes that syslog directs logs to (from the entire ne

2条回答
  •  我在风中等你
    2021-02-15 14:06

    First simplification - handle each named pipe in a separate process. That means you will run one perl process for each named pipe, but then you won't have to use event-based I/O or threading.

    Given that, how about just passing the configuration data (path to the named pipe, email address to use, etc.) on the command line, e.g.:

    the-daemon --pipe /path/to/named-pipe-A --mailto root@domainA.com
    the-daemon --pipe /path/to/named-pipe-B --mailto root@domainB.com
    ...
    

    Does that work for you?

    To make sure the daemons stay up, have a look at a package like D. J. Bernstein's daemontools or supervisord (gasp! a python package).

    Each of these packages tells you how to configure your rc-scripts so that they start at machine boot time.

提交回复
热议问题