[dancer-users] How can a fork+system() Dancer app not create zombie processes?
shlomif at shlomifish.org
Mon Apr 3 09:01:23 BST 2017
When running a simple and reduced Dancer 1 application which forks and runs
perldoc -f system , I am getting many zombie processes after making requests.
This does not happen with
which does the same thing using IO::Socket and plain TCP.
To reproduce, do:
hg clone https://email@example.com/shlomif/app-notifier
hg checkout zombies-processes-bug
And then run “bash run-server.bash” and in a different shell session
“bash run-client.bash.” . You can run 'pstree -p' to see the zombies processes.
This happens on Mageia v6 x86-64 and Fedora 25 x86-64 with
I am quoting a discussion I had on #dancer on irc.perl.org about it. Any
further insights about a solution will be welcome.
Apr 02 16:47:21 <rindolf> Hi all! My dancer service here (run run-server.bash and then run-client.bash in the App-Notifier-Service directory and note the branch) generates many zombie processes - how can I prevent it from happening? https://bitbucket.org/shlomif/app-notifier/branch/zombies-processes-bug
Apr 02 16:54:58 <racke> how do you start the dancer service?
Apr 02 16:55:57 <rindolf> racke: perl -I"`pwd`/lib" bin/app.pl --port=6300
Apr 02 16:56:25 <racke> so that is Dancer 1 ?
Apr 02 16:56:40 <rindolf> racke: yes, it is
Apr 02 16:58:36 <racke> you start only one instance so i might not be able to handle the incoming request
Apr 02 16:59:32 <rindolf> racke: it handles most requests fine
Apr 02 16:59:36 <racke> better use something like plackup -s Starman --workers=5
Apr 02 17:01:13 <rindolf> racke: what do I need it for?
Apr 02 17:01:38 <racke> as I explained before
Apr 02 17:01:44 <racke> you need more than one instance
Apr 02 17:02:33 <rindolf> racke: see https://metacpan.org/pod/App::Notifier::Service for my use case
Apr 02 17:02:38 <rindolf> racke: why?
Apr 02 17:03:08 <rindolf> racke: i don't need to handle moer than one request at the time
Apr 02 17:03:23 <racke> hm
Apr 02 17:03:30 <racke> if you think so
Apr 02 17:05:01 <racke> you probably don't handle fork correctly, that is likely to cause your zombies
Apr 02 17:05:27 <rindolf> racke: I followed perldoc perlipc
Apr 02 17:10:42 <racke> well why not use something like IPC::RUn?
Apr 02 17:16:33 <rindolf> racke: 1. I used fork+system - it is enough for my needs, 2. I provided a link to the code - did you take a look? 3. I found IPC::Run buggy when i used it in a different project
Apr 02 17:17:22 <rindolf> racke: and also - this is the reduced-to-a-minimum code
Apr 02 17:19:23 <racke> yeah I did take a look
Apr 02 17:19:49 <rindolf> racke: ok, thanks!
Apr 02 17:20:09 <racke> I am not familar with using fork so ...
Apr 02 17:20:33 <racke> but it looks like it produces your army of zombies :-)
Apr 02 18:01:22 <rindolf> racke: the IO-Socket-INET equivalent does not spawn any zombies - https://github.com/shlomif/shlomif-perl-snippets/blob/master/tcp-socket-server-w-fork.pl
Apr 02 18:07:07 <rindolf> http://stackoverflow.com/questions/13614498/forking-to-run-code-in-a-child-process-with-perls-dancer - there is this too
Shlomi Fish http://www.shlomifish.org/
My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/
Chuck Norris can end world hunger, but he thinks that hungry people make
humanity a more challenging adversary.
Please reply to list if it's a mailing list post
More information about the dancer-users