Skip to content
Edsko de Vries edited this page Aug 22, 2013 · 2 revisions

To set up a default Hackage server, just cabal install it. If you want to extend the server or disable features, you should unpack the source, modify the feature modules (Distribution.Server.Feature and Distribution.Server.State), and install it from there.

This is taken from the GetOpt output for hackage-server. Once you've installed the hackage-server application (please report build problems), you can use it as follows:

Overview

Usage: hackage-server COMMAND [FLAGS]
   or: hackage-server [GLOBAL FLAGS]

Global flags:
 -h --help    Show this help text
 -V --version Print version information

Commands:
  run            Run an already-initialized Hackage server.
  init           Initialize the server state to a useful default.
  backup         Create a backup of the server's database.
  restore        Restore server state from a backup tarball.
  test-backup    A self-test of the server's database backup/restore system.
  help           Help about commands

Mode descriptions

Run mode

Run an already-initialized Hackage server.

Usage: hackage-server run [FLAGS]

Flags for run:
 -h --help                        Show this help text
 -v --verbose[=n]                 Control verbosity (n is 0--3, default
                                  verbosity level is 1)
    --port=PORT                   Port number to serve on (default 8080)
    --ip=IP                       IPv4 address to listen on (default 0.0.0.0)
    --base-uri=NAME               Server's public base URI (defaults to machine
                                  name)
    --state-dir=DIR               Directory in which to store the persistent
                                  state of the server (default state/)
    --static-dir=DIR              Directory in which to find the html templates
                                  and static files (default: cabal location)
    --tmp-dir=DIR                 Temporary directory in which to store file
                                  uploads (default state/tmp/)
    --temp-run                    Set up a temporary server while initializing
                                  state for maintenance restarts
    --delay-cache-updates=SECONDS Save time during bulk imports by delaying
                                  cache updates.
 -o --output-dir=TARBALL          The directory in which to create the backup
                                  (default ./backups/)
    --hardlink-blobs              Hard-link the blob files in the backup rather
                                  than copying them (reduces disk space and I/O
                                  but is less robust to errors).

Note: the hackage-server data lock prevents two state-accessing modes from
being run simultaneously.

On unix systems you can tell the server to checkpoint its database state using:
 $ kill -USR1 $the_pid
where $the_pid is the process id of the running server. Similarly,
 $ kill -USR2 $the_pid
starts an online backup.

New mode

Creates an empty package collection and one admininstrator account so that you can log in via the web interface and bootstrap from there.

Usage: hackage-server init [FLAGS]

Flags for init:
 -h --help            Show this help text
 -v --verbose[=n]     Control verbosity (n is 0--3, default verbosity level is
                      1)
    --admin=NAME:PASS New server's administrator, name:password (default:
                      admin:admin)
    --state-dir=DIR   Directory in which to store the persistent state of the
                      server (default state/)
    --static-dir=DIR  Directory in which to find the html templates and static
                      files (default: cabal location)

Restore mode

What it says on the tin. This can't be done when there's existing server state. In theory it would be easy to restore selectively for certain features, but this might cause major inconsistency issues.

Usage: hackage-server restore [FLAGS]

Flags for restore:
 -h --help           Show this help text
 -v --verbose[=n]    Control verbosity (n is 0--3, default verbosity level is
                     1)
    --state-dir=DIR  Directory in which to store the persistent state of the
                     server (default state/)
    --static-dir=DIR Directory in which to find the html templates and static
                     files (default: cabal location)

Backup mode

Export a backup tarball from server state. Backup all of the server's data into a human-readable snapshot tarball. This may contain confidential information like passwords and email addresses!

Because happstack-state's data lock prevents two processes from accessing the same data store, you have to shut down the server to do this. Alternatively, you can send SIGUSR2 to the server to start an online backup process (see "Run mode", above).

Usage: hackage-server backup [FLAGS]

Flags for backup:
 -h --help               Show this help text
 -v --verbose[=n]        Control verbosity (n is 0--3, default verbosity level
                         is 1)
    --state-dir=DIR      Directory in which to store the persistent state of
                         the server (default state/)
    --static-dir=DIR     Directory in which to find the html templates and
                         static files (default: cabal location)
 -o --output-dir=TARBALL The directory in which to create the backup (default
                         ./backups/)
    --hardlink-blobs     Hard-link the blob files in the backup rather than
                         copying them (reduces disk space and I/O but is less
                         robust to errors).