{
    "content": [
        {
            "type": "text",
            "text": "# Net::Server::PreFork (perldoc)\n\n## NAME\n\nNet::Server::PreFork - Net::Server personality\n\n## SYNOPSIS\n\nuse base qw(Net::Server::PreFork);\nsub processrequest {\n#...code...\n}\nPACKAGE->run();\n\n## DESCRIPTION\n\nPlease read the pod on Net::Server and Net::Server::PreForkSimple first. This module is a\npersonality, or extension, or sub class, of the Net::Server::PreForkSimple class which is a sub\nclass of Net::Server. See Net::Server::PreForkSimple.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **SAMPLE CODE**\n- **COMMAND LINE ARGUMENTS**\n- **CONFIGURATION FILE**\n- **PROCESS FLOW**\n- **HOOKS**\n- **HOT DEPLOY**\n- **BUGS**\n- **TO DO**\n- **AUTHOR**\n- **THANKS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Net::Server::PreFork",
        "section": "",
        "mode": "perldoc",
        "summary": "Net::Server::PreFork - Net::Server personality",
        "synopsis": "use base qw(Net::Server::PreFork);\nsub processrequest {\n#...code...\n}\nPACKAGE->run();",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 13,
                "subsections": []
            },
            {
                "name": "SAMPLE CODE",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "COMMAND LINE ARGUMENTS",
                "lines": 56,
                "subsections": []
            },
            {
                "name": "CONFIGURATION FILE",
                "lines": 43,
                "subsections": []
            },
            {
                "name": "PROCESS FLOW",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "HOOKS",
                "lines": 26,
                "subsections": []
            },
            {
                "name": "HOT DEPLOY",
                "lines": 5,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "TO DO",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "THANKS",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 4,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Net::Server::PreFork - Net::Server personality\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use base qw(Net::Server::PreFork);\n\nsub processrequest {\n#...code...\n}\n\nPACKAGE->run();\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Please read the pod on Net::Server and Net::Server::PreForkSimple first. This module is a\npersonality, or extension, or sub class, of the Net::Server::PreForkSimple class which is a sub\nclass of Net::Server. See Net::Server::PreForkSimple.\n\nThis personality binds to one or more ports and then forks \"minservers\" child process. The\nserver will make sure that at any given time there are \"minspareservers\" available to receive\na client request, up to \"maxservers\". Each of these children will process up to \"maxrequests\"\nclient connections. This type is good for a heavily hit site, and should scale well for most\napplications. (Multi port accept is accomplished using flock to serialize the children).\n\nAt this time, it does not appear that this module will pass tests on Win32 systems. Any ideas or\npatches for making the tests pass would be welcome.\n",
                "subsections": []
            },
            "SAMPLE CODE": {
                "content": "Please see the sample listed in Net::Server.\n",
                "subsections": []
            },
            "COMMAND LINE ARGUMENTS": {
                "content": "In addition to the command line arguments of the Net::Server base class and the\nNet::Server::PreForkSimple parent class, Net::Server::PreFork contains several other\nconfigurable parameters. You really should also see Net::Server::PreForkSimple.\n\nKey                 Value                   Default\nminservers         \\d+                     5\nminspareservers   \\d+                     2\nmaxspareservers   \\d+                     10\nmaxservers         \\d+                     50\nmaxrequests        \\d+                     1000\n\nserialize           (flock|semaphore\n|pipe|none)            undef\n# serialize defaults to flock on multiport or on Solaris\nlockfile           \"filename\"              File::Temp->new\n\ncheckfordead      \\d+                     30\ncheckforwaiting   \\d+                     10\n\nmaxdequeue         \\d+                     undef\ncheckfordequeue   \\d+                     undef\n\nchildcommunication 1                       undef\n\nminservers\nThe minimum number of servers to keep running.\n\nminspareservers\nThe minimum number of servers to have waiting for requests. Minimum and maximum numbers\nshould not be set to close to each other or the server will fork and kill children too\noften.\n\nmaxspareservers\nThe maximum number of servers to have waiting for requests. See *minspareservers*.\n\nmaxservers\nThe maximum number of child servers to start. This does not apply to dequeue processes.\n\ncheckforwaiting\nSeconds to wait before checking to see if we can kill off some waiting servers.\n\ncheckforspawn\nSeconds between checking to see if we need to spawn more children\n\nminchildttl\nMinimum number of seconds between starting children and killing a child process\n\nchildcommunication\nEnable child communication to parent via unix sockets. If set to true, will let children\nwrite to the socket contained in $self->{'server'}->{'parentsock'}. The parent will be\nnotified through childistalkinghook where the first argument is the socket to the child.\nThe child's socket is stored in $self->{'server'}->{'children'}->{$childpid}->{'sock'}.\n\nserialize\nSee the documentation under Net::Server::PreForkSimple.\n",
                "subsections": []
            },
            "CONFIGURATION FILE": {
                "content": "\"Net::Server::PreFork\" allows for the use of a configuration file to read in server parameters.\nThe format of this conf file is simple key value pairs. Comments and white space are ignored.\n\n#-------------- file test.conf --------------\n\n### server information\nminservers   20\nmaxservers   80\nminspareservers 10\nminspareservers 15\n\nmaxrequests  1000\n\n### user and group to become\nuser        somebody\ngroup       everybody\n\n### logging ?\nlogfile    /var/log/server.log\nloglevel   3\npidfile    /tmp/server.pid\n\n### access control\nallow       .+\\.(net|com)\nallow       domain\\.com\ndeny        a.+\n\n### background the process?\nbackground  1\n\n### ports to bind\nhost        127.0.0.1\nport        localhost:20204\nport        20205\n\n### reverse lookups ?\n# reverselookups on\n\n### enable child communication ?\n# childcommunication\n\n#-------------- file test.conf --------------\n",
                "subsections": []
            },
            "PROCESS FLOW": {
                "content": "Process flow follows Net::Server until the loop phase. At this point \"minservers\" are forked\nand wait for connections. When a child accepts a connection, finishes processing a client, or\nexits, it relays that information to the parent, which keeps track and makes sure there are\nenough children to fulfill \"minservers\", \"minspareservers\", \"maxspareservers\", and\n\"maxservers\".\n",
                "subsections": []
            },
            "HOOKS": {
                "content": "The PreFork server has the following hooks in addition to the hooks provided by PreForkSimple.\nSee Net::Server::PreForkSimple.\n\n\"$self->runnchildrenhook()\"\nThis hook occurs at the top of runnchildren which is called each time the server goes to\nstart more child processes. This gives the parent to do a little of its own accounting (as\ndesired). Idea for this hook came from James FitzGibbon.\n\n\"$self->parentreadhook()\"\nThis hook occurs any time that the parent reads information from the child. The line from\nthe child is sent as an argument.\n\n\"$self->childistalkinghook()\"\nThis hook occurs if childcommunication is true and the child has written to\n$self->{'server'}->{'parentsock'}. The first argument will be the open socket to the child.\n\n\"$self->idleloophook()\"\nThis hook is called in every pass through the main process wait loop, every\n\"checkforwaiting\" seconds. The first argument is a reference to an array of file\ndescriptors that can be read at the moment.\n\n\"$self->cleanupdeadchildhook( $child )\"\nThis hook is called when a dead child is detected. A child is considered dead when the pid\ndoes no longer exist. This hook could be used to cleanup possible temporary files or locks\nleft over by a dead child.\n",
                "subsections": []
            },
            "HOT DEPLOY": {
                "content": "Since version 2.000, the PreFork server has accepted the TTIN and TTOU signals. When a TTIN is\nreceived, the min and maxservers are increased by 1. If a TTOU signal is received the min\nmaxservers are decreased by 1. This allows for adjusting the number of handling processes\nwithout having to restart the server.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "Tests don't seem to work on Win32. Any ideas or patches would be welcome.\n",
                "subsections": []
            },
            "TO DO": {
                "content": "See Net::Server\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Paul T. Seamons paul@seamons.com\n",
                "subsections": []
            },
            "THANKS": {
                "content": "See Net::Server\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Please see also Net::Server::Fork, Net::Server::INET, Net::Server::PreForkSimple,\nNet::Server::MultiType, Net::Server::Single Net::Server::SIG Net::Server::Daemonize\nNet::Server::Proto\n",
                "subsections": []
            }
        }
    }
}