I've used the POE module family to do event daemons
On 11/23/2016 03:55 PM, Chris Fedde wrote:
It might not be too bad an idea to just use processes rather than getting
wrapped up in event loops and asynch IO.
Forking is cheap and fast in linux. In my opinion it gets overlooked for many
cases where it is a perfectly acceptable approach.
There are lots of approaches to work queues. The main architectural approach
is how close the coupling needs to be between the requester and the worker.
One of my favorite, simple approaches is to put files into a directory. Each
file represents a tasks and perhaps contains interesting metadata.
chris
On Wed, Nov 23, 2016 at 7:36 AM, Gary Stainburn <gary.stainb...@ringways.co.uk
<mailto:gary.stainb...@ringways.co.uk>> wrote:
On Wednesday 23 November 2016 14:05:40 Shlomi Fish wrote:
> Aside from named pipes there are also unix-domain sockets and TCP sockets,
> both of which are more robust.
The closest thing I've got to IPC is writing an xinetd service, which I then
called from perl scripts using Net::Telnet. IPC is therefore one of the
things I'm going to have to learn. The Domoticz service that I'm supporting
is itself an event driven service which runs pretty much all of my house.
The key requirement of whatever method I use is that I cannot under any
circumstance block Domoticz. That is one reason I'm wary of using a pipe..
If my server dies, then writing to the pipe will block. The benefit of a
pipe
is that it's very simple to code in however many ways I need, Perl, LUA
etc.
(LUA is embedded in Domoticz)
I have considered using a standard text file rather than a pipe, allowing
anything to append to the pipe, then my daemon reading when it's ready. One
things I have found to help with this is:
https://gist.github.com/sugar84/1198879
<https://gist.github.com/sugar84/1198879>
which is an example of tail -f to a pipe. As Domoticz already writes to a
log
file, I should be able to readm input from there too and respond to both
(hopefully)
> Last time I checked, AnyEvent erred if IO-Async which is a different
> alternative was also used, causing some people to avoid using AnyEvent. I
> ended up sticking with AnyEvent for
> https://metacpan.org/release/App-ManiacDownloader
<https://metacpan.org/release/App-ManiacDownloader> because IO-Async's
> support for FTP was lacking.
Are you saying that the problem only arrises if I use both AnyEvent and
IO-Async? I haven't had a look at the latter, but I doubt (hope) that my
daemon won't get too complicated.
>
> Also see the page I wrote here - http://perl-begin.org/uses/multitasking/
<http://perl-begin.org/uses/multitasking/> .
> There's also https://metacpan.org/release/Reflex
<https://metacpan.org/release/Reflex> which I think is a
> Moose-based rethinking of POE .
Thanks for the extra links. I'll have a good look at them all before
starting.
Gary
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
<mailto:beginners-unsubscr...@perl.org>
For additional commands, e-mail: beginners-h...@perl.org
<mailto:beginners-h...@perl.org>
http://learn.perl.org/
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/