Think about Loose Coupling | |
PerlMonks |
Re: Stopping an HTTP::Server::Simple serverby textual (Novice) |
on Jan 26, 2011 at 13:07 UTC ( [id://884333]=note: print w/replies, xml ) | Need Help?? |
I'm facing the same problem, though not in a testing situation. Following Corion's advice, I'm trying to pass the server's PID (returned by its background() method) to a handler that will be responsible for killing it. My problem is that I can't find a way to pass the PID to the handler. I've tried several things which all end up the same way when I access the url associated to the handler: the PID's value has not been passed and Perl "Can't kill a non-numeric process ID". I've tried this (where the setup is maximally contrived for brevity): A) Store PID as a global in the main package and access it from the server package. In test.pl:And in Webserver.pm:
B) Store PID as a global in the server package and set it in the main package. In test.pl:And in Webserver.pm:
C) Store the PID in a separate module used by test.pl and webserver.pm. In test.pl:In Webserver.pm: And in Pid.pm:
I've tried even more esoteric things until I started to feel like Wile E. Coyote, so I think it's time I submit this problem to you. Any advice would be welcome, and so would any explanation as to what I fail to understand.
In Section
Seekers of Perl Wisdom
|
|