pgxn_site_server - The PGXN API server


  pgxn_site_server --api-url \
                   --errors-to \
                   --errors-from \


This is the PGXN main site PSGI server. It automatically figures out the environment it is run in, and runs your application in that environment. FastCGI, CGI, AnyEvent and others can all be detected. See Plack::Loader for the authoritative list.


     --api-url          URL    URL for the PGXN API server.
     --private-api-url  URL    URL to a private API server.
     --errors-to        EMAIL  Email to which error messages should be sent.
     --errors-from      EMAIL  Email to use on the From line of error messages.
     --feedback-to      EMAIL  Email to which users can submit feedback.
     --reverse-proxy           Run behind a reverse proxy server.
  -o --host                    Bind TCP daemon to the specified interface.
  -p --port                    Listen on the specified TCP port.
  -s --server                  Plack server to use.
  -S --socket                  UNIX domain socket path to listen on.
  -l --listen                  Address to listen on.
  -D --daemonize               Make the process go to the background.
  -I                   PATH    Specify a Perl include library path.
  -E --env             ENV     Run with the specified environment.
  -r --reload                  Reload when a development file changes.
  -R --Reload          PATH    Reload when a file in the specified path changes.
  -L --loader          LOADER  Run with specified loading class.
     --access-log      PATH    Write access log to the specified file.
  -h --help                    Print a usage statement and exit.
  -m --man                     Print the complete documentation and exit.
  -v --version                 Print the version number and exit.

Option Details


URL for a PGXN::API-powered API server. Most of the site content comes from the API and many links go back to it.


URL for a private PGXN::API-powered API server. Useful if the API server is on the same box or a shared file system, as you can then use a file: URL to access the content directly from the file system rather than over HTTP.


Specify an email address to which to send error information. Whenever the server encounters a 500 error, it will send detailed information, including a stack trace, to this address.


The email address from which error messages should appear to be sent.


Specify an email address to be published in the app as a link. Users will be able to click the link to send feedback about the site.


Specify this option if the server is running behind a reverse proxy server. This activate the Plack::Middleware::ReverseProxy middleware, which fixes proxied requests so that end-user client data is properly available to the app (and URLs in the app will be correct).

-o, --host

The interface a TCP based server daemon binds to. Defaults to undef, which lets most server back ends bind the any (*) interface. This option does nothing if the server does not support TCP socket.

-p, --port

The port number a TCP based server daemon listens on. Defaults to 5000. This option does nothing if the server does not support TCP socket.

-s, --server

Select a specific implementation to run on using the PLACK_SERVER environment variable or use the -s or --server flag which will be preferred over the environment variable.

-S, --socket

UNIX domain socket path to listen on. Defaults to undef. This option does nothing if the server doesn't support UNIX sockets.

-l, --listen

Addresses on which to listen. It could be HOST:PORT, :PORT or PATH (without colons). It could be multiple but it depends on the server implementations whether multiple interfaces are supported.

-D, --daemonize

Makes the process go background. It's up to the back end server/handler implementation whether this option is respected or not.


Specify perl library include path, like perl's -I option.

-E, --env

Specify the environment option (default is development). You can set this value by setting PLACK_ENV environment variable as well, and specifying the value with the command line options writes back to PLACK_ENV as well, so the API server can tell which environment setting the application is running on.

  # These two are the same
  pgxn_site_server -E deployment
  env PLACK_ENV=deployment pgxn_site_server

The value can be anything but commonly used ones are development, deployment and test.

If it's set to development, following middleware components are enabled by default: AccessLog, StackTrace and Lint.

-r, --reload

Watch for updates in your development directory and restart the server whenever a file is updated. This option by default watches the lib directory. Use -R if you want to watch other directories.

-R, --Reload

-R option allows you to specify the path to watch file updates separated by comma (,).

  pgxn_site_server -R /path/to/project/lib,/path/to/project/templates
-L, --loader

Specify the server loading subclass that implements how to run the server. Available options are Plack::Loader (default), Restarter (automatically set when -r or -R is used), Delayed and Shotgun.

See Plack::Loader::Delayed and Plack::Loader::Shotgun when to use those loader types.


Specify the path to a file where the access log should be written. By default, in the development environment access logs will go to STDERR.

-h --help

Outputs usage information and exits.

-m --man

Outputs this full documentation and exits.

-v --version

Outputs the version and exits.

Other options that starts with -- are passed through to the back end server. See the appropriate Plack::Handler back end documentation to see which options are available.

See Also


David E. Wheeler <>

Copyright and License

Copyright (c) 2010-2021 David E. Wheeler.

This module is free software; you can redistribute it and/or modify it under the PostgreSQL License.

Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.

In no event shall David E. Wheeler be liable to any party for direct, indirect, special, incidental, or consequential damages, including lost profits, arising out of the use of this software and its documentation, even if David E. Wheeler has been advised of the possibility of such damage.

David E. Wheeler specifically disclaims any warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The software provided hereunder is on an "as is" basis, and David E. Wheeler has no obligations to provide maintenance, support, updates, enhancements, or modifications.