<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">NAME
    Gepok - PSGI server with built-in HTTPS support, Unix sockets,
    preforking

VERSION
    version 0.12

SYNOPSIS
    To run with plackup:

     % plackup -s Gepok --daemonize

    To run standalone:

     #!/usr/bin/perl
     use Gepok;
     my $d = Gepok-&gt;new(
         http_ports     =&gt; [8081, ':8082', '127.0.0.1:8083'], # default none
         https_ports    =&gt; [8084, '0.0.0.0:8085'],            # default none
         unix_sockets   =&gt; ['/var/run/gepok.sock','/tmp/gepok.sock'], # default none
         #ssl_key_file  =&gt; '/path/to/key.pem', # required if https_ports specified
         #ssl_cert_file =&gt; '/path/to/crt.pem', # required if https_ports specified
         #max_requests_per_child =&gt; 100,       # default is 1000
         #start_servers          =&gt; 0,         # default is 3, 0 means don't prefork
         #daemonize =&gt; 0,       # default is 1, 0 = don't go into background
     );
     $d-&gt;run($psgi_app);

DESCRIPTION
    Gepok is a PSGI server implementation. Its features are:

    *   HTTPS support out-of-the-box

        This is the primary (if not the only) reason why I wrote Gepok, and
        why it uses HTTP::Daemon::* family (because there is
        HTTP::Daemon::SSL). I needed a pure-Perl standalone webserver with
        SSL support builtin. Other Perl servers usually recommend running
        behind Nginx or some other external HTTPS proxy.

    *   Preforking

        Good performance and reliability.

    *   Multiple interface and Unix socket

    *   Runs on Unix platform

    Gepok can run under plackup, or standalone.

    This module uses Log::Any for logging.

    This module uses Moo for object system.

PSGI ENVIRONMENT
    Gepok adds the following server-specific keys in the PSGI environment
    passed to application/middleware:

    *   gepok.connect_time

        A 2-element arrayref (produced by Time::HiRes' gettimeofday()),
        clocked at connect time.

    *   gepok.finish_request_time

        A 2-element arrayref (produced by Time::HiRes' gettimeofday()),
        clocked right after Gepok has received the complete request from
        client.

ATTRIBUTES
  name =&gt; STR (default is basename of $0)
    Name of server, for display in process table ('ps ax').

  daemonize =&gt; BOOL (default 1)
    Whether to daemonize (go into background).

  http_ports =&gt; ARRAY OF STR (default [])
    One or more HTTP ports to listen to. Default is none. Each port can be
    in the form of N, ":N", "0.0.0.0:N" (all means the same thing, to bind
    to all interfaces) or "1.2.3.4:N" (to bind to a specific network
    interface).

    A string is also accepted, it will be split (delimiter ,) beforehand.

  https_ports =&gt; ARRAY OF STR (default [])
    Just like http_ports, but for specifying ports for HTTPS.

  unix_sockets =&gt; ARRAY OF STR (default [])
    Location of Unix sockets. Default is none, which means not listening to
    Unix socket. Each element should be an absolute path.

    A string is also accepted, it will be split (delimiter ,) beforehand.

    You must at least specify one port (either http, https, unix_socket) or
    Gepok will refuse to run.

  timeout =&gt; BOOL (default 120)
    Socket timeout. Will be passed as Timeout option to HTTP::Daemon's
    constructor (which will be passed to IO::Socket).

  require_root =&gt; BOOL (default 0)
    Whether to require running as root.

    Passed to SHARYANTO::Proc::Daemon::Prefork's constructor.

  pid_path =&gt; STR (default /var/run/&lt;name&gt;.pid or ~/&lt;name&gt;.pid)
    Location of PID file.

  scoreboard_path =&gt; STR (default /var/run/&lt;name&gt;.scoreboard or ~/&lt;name&gt;.scoreboard)
    Location of scoreboard file (used for communication between parent and
    child processes). If you disable this, autoadjusting number of children
    won't work (number of children will be kept at 'start_servers').

  error_log_path =&gt; STR (default /var/log/&lt;name&gt;-error.log or ~/&lt;name&gt;-error.log)
    Location of error log. Default is /var/log/&lt;name&gt;-error.log. It will be
    opened in append mode.

  access_log_path =&gt; STR (default /var/log/&lt;name&gt;-access.log or ~/&lt;name&gt;-access.log)
    Location of access log. It will be opened in append mode.

    Default format of access log is the Apache combined format. Override
    access_log() method if you wan't to customize this.

    If Gepok is run Under plackup, by default it will not write an access
    log file (unless you specify this attribute) since plackup already
    writes an access log.

  ssl_key_file =&gt; STR
    Path to SSL key file, to be passed to HTTP::Daemon::SSL. If you specify
    one or more HTTPS ports, you need to supply this.

  ssl_cert_file =&gt; STR
    Path to SSL cert file, to be passed to HTTP::Daemon::SSL. If you specify
    one or more HTTPS ports, you need to supply this.

  start_servers =&gt; INT (default 3)
    Number of children to fork at the start of run. If you set this to 0,
    the server becomes a nonforking one.

    Tip: You can set start_servers to 0 and 'daemonize' to false for
    debugging.

  max_clients =&gt; INT (default 150)
    Maximum number of children processes to maintain. If server is busy,
    number of children will be increased from the original 'start_servers'
    up until this value.

  max_requests_per_child =&gt; INT (default 1000)
    Number of requests each child will serve until it exists.

  product_name =&gt; STR
    Used in 'Server' HTTP response header (&lt;product_name&gt;/&lt;version&gt;).
    Defaults to class name, e.g. "Gepok".

  product_version =&gt; STR
    Used in 'Server' HTTP response header (&lt;product_name&gt;/&lt;version&gt;).
    Defaults to $VERSION package variable.

METHODS
  new(%args)
    Create a new instance of server. %args can be used to set attributes.

  $gepok-&gt;run($app)
    Start/run server and run the PSGI application $app.

  $gepok-&gt;start($app)
    Alias for run().

  $gepok-&gt;stop()
    Stop running server.

  $gepok-&gt;restart()
    Restart server.

  $gepok-&gt;is_running() =&gt; BOOL
    Check whether server is running.

  $gepok-&gt;before_prefork()
    This is a hook provided for subclasses to do something before the daemon
    is preforking. For example, you can preload Perl modules here so that
    each child doesn't have to load modules separately (= inefficient).

  $gepok-&gt;access_log($req, $res, $sock)
    The default implementation uses the Apache combined format. Override if
    you want custom format. $res is HTTP::Request object, $res is PSGI
    response, $sock is the raw socket.

FAQ
  Why the name Gepok?
    Gepok is an Indonesian word, meaning bundle/bunch. This class bundles
    one or several HTTP::Daemon::* objects to create a stand-alone web
    server.

  Performance notes?
    Thanks to preforking, Gepok has adequate performance and reliability
    handling multiple clients. But Gepok is not yet performance-tuned, or
    very performance-oriented to begin with. For convenience Gepok is based
    on HTTP::Daemon, which is also not too performance-oriented. For each
    HTTP request, HTTP::Daemon constructs an HTTP::Request object, which
    copies request body into a scalar (and, for PSGI, needs to be
    re-presented as a stream using IO::Scalar). Creating other objects like
    URI and HTTP::Headers are also involved. Gepok also creates file-based
    scoreboard, which might or might not be a bottleneck.

    Casual benchmarking on my PC shows that Gepok is about 3-4x slower than
    Starman for "hello world" PSGI.

    I am using Gepok primarily with Sub::Spec::HTTP::Server for serving
    remote API requests, in which HTTPS support is required.

CREDITS
    Some code portion taken from Starman.

SEE ALSO
    PSGI and Plack.

    HTTP server classes used: HTTP::Daemon, HTTP::Daemon::SSL,
    HTTP::Daemon::UNIX.

    Alternative PSGI servers: Starman (a high-performance preforking Perl
    HTTP/1.1 server which also supports Unix socket and multiple ports, but
    doesn't support HTTPS out-of-the-box), Starlet (preforking and HTTP/1.1
    but no multiple ports/Unix sockets/HTTPS).

AUTHOR
    Steven Haryanto &lt;stevenharyanto@gmail.com&gt;

COPYRIGHT AND LICENSE
    This software is copyright (c) 2011 by Steven Haryanto.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

</pre></body></html>