Mojolic...:prefork(3)

πŸ’… Mojolicious::Command::prefork

okay so bestie, you're reading the prefork man page β€” it lives in section 3 of the User Contributed Perl Documentation, and it's genuinely one of the most useful little gremlins in the whole Mojolicious toolbox. let's get into it 🫢


✨ NAME ✨

Mojolicious::Command::prefork β€” the Pre-fork command. that's it, that's the name, she's literally named what she does πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

the vibe check, in code:

Usage: APPLICATION prefork [OPTIONS]

and here's how the girlies actually run it:

  ./myapp.pl prefork
  ./myapp.pl prefork -m production -p -l http://*:8080
  ./myapp.pl prefork -l http://127.0.0.1:8080 -l https://[::]:8081
  ./myapp.pl prefork -l 'https://*:443?cert=./server.crt&key=./server.key'
  ./myapp.pl prefork -l http+unix://%2Ftmp%2Fmyapp.sock -w 12
  ./myapp.pl prefork -l http://127.0.0.1:8080 -p 127.0.0.0/8 -p fc00::/7

⭐ Options ⭐

every single flag, no gatekeeping, no cap:

  • -a, --accepts <number> β€” how many connections each worker will accept. defaults to 10000.
  • -b, --backlog <size> β€” listen backlog size. defaults to SOMAXCONN.
  • -c, --clients <number> β€” max number of concurrent connections. defaults to 1000.
  • -G, --graceful-timeout <seconds> β€” graceful timeout. defaults to 120. (yes the period is right there in the original, respect her punctuation πŸ™ˆ).
  • -I, --heartbeat-interval <seconds> β€” heartbeat interval. defaults to 5.
  • -H, --heartbeat-timeout <seconds> β€” heartbeat timeout. defaults to 50.
  • -h, --help β€” show this summary of available options. the classic.
  • --home <path> β€” path to the home directory of your application. defaults to the value of MOJO_HOME or auto-detection.
  • -i, --inactivity-timeout <seconds> β€” inactivity timeout. defaults to the value of MOJO_INACTIVITY_TIMEOUT or 30.
  • -k, --keep-alive-timeout <seconds> β€” keep-alive timeout. defaults to the value of MOJO_KEEP_ALIVE_TIMEOUT or 5.
  • -l, --listen <location> β€” one or more locations you want to listen on. defaults to the value of MOJO_LISTEN or "http://*:3000".
  • -m, --mode <name> β€” operating mode for your application. defaults to the value of MOJO_MODE/PLACK_ENV or "development".
  • -P, --pid-file <path> β€” path to the process id file. defaults to "prefork.pid" in a temporary directory.
  • -p, --proxy [<network>] β€” activate reverse proxy support. defaults to the value of MOJO_REVERSE_PROXY, and optionally takes one or more trusted proxy addresses or networks.
  • -r, --requests <number> β€” max number of requests per keep-alive connection. defaults to 100.
  • -s, --spare <number> β€” temporarily spawn up to this number of additional workers. defaults to 2.
  • -w, --workers <number> β€” number of workers. defaults to 4.

πŸ¦‹ DESCRIPTION πŸ¦‹

so Mojolicious::Command::prefork starts applications with the Mojo::Server::Prefork backend. that's the whole assignment, and she ate πŸ”₯

this is a core command, which means it is always enabled β€” and its code is a genuinely good example for learning to build new commands. you're welcome to fork it, like literally, forking is the whole theme here 🧚

also: see "COMMANDS" in Mojolicious::Commands for a list of commands that are available by default. iykyk.


πŸ‘‘ ATTRIBUTES πŸ‘‘

Mojolicious::Command::prefork inherits all attributes from Mojolicious::Command and implements the following new ones. family traits, but make it fresh ✨

πŸ’– description

my $description = $prefork->description;
$prefork        = $prefork->description('Foo');

short description of this command, used for the command list. it's her little one-liner in the group chat bio πŸ’…

πŸ’– usage

my $usage = $prefork->usage;
$prefork  = $prefork->usage('Foo');

usage information for this command, used for the help screen. the "how do i use this" text, basically.


🌈 METHODS 🌈

Mojolicious::Command::prefork inherits all methods from Mojolicious::Command and implements the following new ones. the icon legacy continues πŸ’œ

🌸 build_server

my $server = $daemon->build_server(@ARGV);

build Mojo::Server::Prefork instance from command line arguments. that's the main character move right there πŸ‘‘

🌸 run

$prefork->run(@ARGV);

run this command. short, sweet, slays.


πŸ’€ SEE ALSO πŸ’€

go read them, bestie, they're free and they're iconic πŸŽ€


ngl this whole page is core-command energy: always on, always available, and a great template if you ever wanna fork it and build your own. no cap 🫢

later, legend ✨ this was perl v5.42.0, dated 2026-07-15, and that's the whole Mojolic...:prefork(3) situation β€” mwah πŸ’‹

πŸ“¦ where this page comes from