KFCGI(8)

๐Ÿ“ฆ version 1.0.1, in alpine 3.24, nixos 26.05, nixpkgs unstable

๐Ÿ’… KFCGI(8) โ€” the FastCGI server for kcgi apps, bestie

okay so this is the manual for kfcgi, from the System Manager's Manual section. yes we're reading a system manager page and yes it's actually kinda iconic. buckle up ๐ŸŽ€


โœจ NAME โœจ

kfcgi โ€” FastCGI server for kcgi applications. that's it, that's the whole name section. short, sweet, ate. ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

kfcgi [-drv] [-l backlog] [-n workers] [-N maxworkers] [-p chroot]
      [-s sockpath] [-u sockuser] [-U procuser] [-w waittime] prog
      [arg0...]

look at all those flags. she's got range. ๐Ÿ‘‘


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so the kfcgi server spin up worker processes of prog to handle FastCGI connections. and here's the slay part โ€” it can handle any FastCGI worker that implements the FastCGI v1.0 Specification, and the ones implementing the FastCGI Extensions for Management Control (that's the -r, -N, and -w ones, iykyk).

now the defaults, because defaults are literally the whole vibe check here: by default it opens the socket /var/www/run/httpd.sock in mode 0660 under the current user and group, changes to a file-system jail in /var/www, daemonises and opens its system log, then starts 3 workers executing prog โ€” and ngl prog must exist relative to the file-system jail root, no cap. the back-log is twice the worker pool size (-n) or, in the event of variable-sized pools, twice the maximum worker size (-N). math! she did the math! ๐Ÿงฎโœจ

the arguments are as follows, and yes i'm listing every single one, because we don't skip. periodt.

๐Ÿ’– OPTIONS ๐Ÿ’–

  • -d โ€” do not daemonise, and on top of syslog, print messages to standard error. very "i want to see what's happening" of you. ๐Ÿ™ˆ
  • -v โ€” be more verbose in output. and bestie, this can produce a lot of output. like. a lot a lot. ๐Ÿ”ฅ
  • -l backlog โ€” the connection backlog. if this is too small, connections get refused and the request errors out ๐Ÿ˜ญ. the operating system will usually truncate this, so don't come for the OS when it does.
  • -n workers โ€” the initial number of workers >1. gotta be more than one, that's the rule. ๐Ÿซถ
  • -N maxworkers โ€” the maximum number of workers in a variable-sized pool. by default this is twice -n. ๐ŸŽ€
  • -p chroot โ€” location of the file-system jail. this one's mandatory ๐Ÿ’€: use the root directory if you insist on being insecure. (dramatic? yes. accurate? also yes.)
  • -r โ€” use a variable-sized pool of workers. โš ๏ธ this can only be used for workers implementing the FastCGI Extensions for Management Control. the pool will be at least (and initially) size -n, maximum size -N, with a release policy dictated by -w. it's giving elastic. it's giving scalable. it's giving main character energy. โœจ
  • -s sockpath โ€” alternative socket path. pick your own adventure. ๐Ÿฆ‹
  • -u sockuser โ€” the user in whose name (user and group) the socket is created. ๐ŸŒธ
  • -U procuser โ€” the user in whose name the process is dropped. yes, dropped. like a hot new single. ๐Ÿ’œ
  • -w waittime โ€” the amount of time in seconds a worker must be idle before being released from a variable-sized pool. by default this is five minutes. patience is a virtue fr fr. โณ

๐Ÿซถ stopping and restarting (very important, don't skip!!)

to properly stop a kfcgi server, send it a SIGTERM. ๐Ÿ›‘

and if you send a SIGHUP to the process, it will restart all workers. ๐Ÿ” lowkey the glow-up button.


โญ EXIT STATUS โญ

the kfcgi utility exits 0 on success, and >0 if an error occurs. classic. iconic. consistent. ๐Ÿ’…


๐ŸŒˆ EXAMPLES ๐ŸŒˆ

on OpenBSD, the default user for the web server is โ€œwwwโ€. assuming we have a server that doesn't need any files, we can run the following to keep it in a safe jail:

# kfcgi -u www -U www -- /fcgi-bin/prog

this will execute /fcgi-bin/prog within the default file-system jail of /var/www as user โ€œwwwโ€. it will create the default socket /var/www/run/httpd.sock in mode 0660 as user โ€œwwwโ€. safe, cozy, jailed, slay. ๐Ÿ โœจ

this can also be extended to run a variable-sized pool of workers that responds to system load:

# kfcgi -r -n 2 -N 100 -w 10 -u www -U www -- /fcgi-bin/prog

this will start with only two servers, but scale it to 100 in the event of a burst of communication. workers started to handle the burst will be terminated after 10 seconds. she scales! she shrinks! she does both! ๐Ÿฆ‹๐Ÿ”ฅ


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

  • kcgi(3) โ€” go read it bestie, it's the whole reason we're here.

๐Ÿ’œ STANDARDS ๐Ÿ’œ

kfcgi implements the โ€œFastCGI Specificationโ€, version 1.0, published 29 April 1996, for properly passing connections to the workers. it also implements the FastCGI Extensions for Management Control, right here: https://kristaps.bsd.lv/kcgi/extending01.html โ€” that's the one for variable-sized worker pools. standards compliant AND cute. we love to see it. ๐ŸŽ€


ok i'm done, go forth and serve some FastCGI, you absolute legend ๐Ÿซถ

this page came from Debian, dated $Mdocdate$, and it's KFCGI(8) โ€” mwah, bye bestie! ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from