Net::Server::PreForkSimple(3) | User Contributed Perl Documentation | Net::Server::PreForkSimple(3) |
Net::Server::PreForkSimple - Net::Server personality
use base qw(Net::Server::PreForkSimple); sub process_request { #...code... } __PACKAGE__->run();
Please read the pod on Net::Server first. This module is a personality, or extension, or sub class, of the Net::Server module.
This personality binds to one or more ports and then forks "max_servers" child processes. The server will make sure that at any given time there are always "max_servers" available to receive a client request. Each of these children will process up to "max_requests" client connections. This type is good for a heavily hit site that can keep "max_servers" processes dedicated to the serving. (Multi port accept defaults to using flock to serialize the children).
At this time, it does not appear that this module will pass tests on Win32 systems. Any ideas or patches for making the tests pass would be welcome.
Please see the sample listed in Net::Server.
In addition to the command line arguments of the Net::Server base class, Net::Server::PreFork contains several other configurable parameters.
Key Value Default max_servers \d+ 50 max_requests \d+ 1000 serialize (flock|semaphore |pipe|none) undef # serialize defaults to flock on multi_port or on Solaris lock_file "filename" File::Temp->new check_for_dead \d+ 30 max_dequeue \d+ undef check_for_dequeue \d+ undef
"Net::Server::PreFork" allows for the use of a configuration file to read in server parameters. The format of this conf file is simple key value pairs. Comments and white space are ignored.
#-------------- file test.conf -------------- ### server information max_servers 80 max_requests 1000 ### user and group to become user somebody group everybody ### logging ? log_file /var/log/server.log log_level 3 pid_file /tmp/server.pid ### access control allow .+\.(net|com) allow domain\.com deny a.+ ### background the process? background 1 ### ports to bind host 127.0.0.1 port localhost:20204 port 20205 ### reverse lookups ? # reverse_lookups on #-------------- file test.conf --------------
Process flow follows Net::Server until the loop phase. At this point "max_servers" are forked and wait for connections. When a child accepts a connection, finishs processing a client, or exits, it relays that information to the parent, which keeps track and makes sure there are always "max_servers" running.
The PreForkSimple server has the following hooks in addition to the hooks provided by the Net::Server base class. See Net::Server
Since version 2.000, the PreForkSimple server has accepted the TTIN and TTOU signals. When a TTIN is received, the max_servers is increased by 1. If a TTOU signal is received the max_servers is decreased by 1. This allows for adjusting the number of handling processes without having to restart the server.
Tests don't seem to work on Win32. Any ideas or patches would be welcome.
See Net::Server
Paul T. Seamons paul@seamons.com
See Net::Server
Please see also Net::Server::Fork, Net::Server::INET, Net::Server::PreFork, Net::Server::MultiType, Net::Server::Single Net::Server::SIG Net::Server::Daemonize Net::Server::Proto
2017-08-10 | perl v5.34.0 |