Name

pgxn_api_server - The PGXN API server

Usage

pgxn_api_server --doc-root    /var/www/api \
          --errors-from oops@example.com \
          --errors-to   alerts@example.com

Description

This is the PGXN API 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.

Options

   --errors-to   EMAIL   Email to which error messages should be sent.
   --errors-from EMAIL   Email to use on the From line of error messages.
   --doc-root    PATH    Location of the API document root.
-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

--errors-to

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.

--errors-from

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

--doc-root

The path to use for the API document root. Should be the same path as that managed by pgxn_api_sync.

-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.

-I

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_api_server -E deployment
env PLACK_ENV=deployment pgxn_api_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_api_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.

--access-log

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

Author

David E. Wheeler <david.wheeler@pgexperts.com>

Copyright and License

Copyright (c) 2011-2024 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.