wai-cli: Command line runner for Wai apps (using Warp) with TLS, CGI, socket activation & graceful shutdown

[ library, public-domain, web ] [ Propose Tags ]

Command line runner for Wai apps (using Warp) with support for UNIX domain sockets, TLS (can be turned off with a cabal flag to avoid compiling the TLS library), CGI, socket activation (systemd-compatible, but see https://codeberg.org/valpackett/soad for a more interesting (and not linux-only) thing than what systemd does), and graceful shutdown (on TERM signal).

[Skip to Readme]


[Index] [Quick Jump]


Automatic Flags

Include warp-tls


Include wai-handler-fastcgi


Enable Unix sockets


Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info


Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.2.0, 0.2.1, 0.2.3
Dependencies ansi-terminal, base (>= && <10), http-types, iproute, monads-tf, network, options, stm, streaming-commons, transformers, unix, wai, wai-extra, wai-handler-fastcgi, warp, warp-tls [details]
License LicenseRef-PublicDomain
Copyright 2017-2021 Val Packett <val@packett.cool>
Author Val Packett
Maintainer val@packett.cool
Revised Revision 2 made by myfreeweb at 2022-10-16T12:33:06Z
Category Web
Home page https://codeberg.org/valpackett/wai-cli
Source repo head: git clone https://codeberg.org/valpackett/wai-cli.git
Uploaded by myfreeweb at 2021-06-24T11:21:51Z
Distributions LTSHaskell:0.2.3, NixOS:0.2.3, Stackage:0.2.3
Reverse Dependencies 3 direct, 2 indirect [details]
Downloads 2835 total (17 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2021-06-24 [all 1 reports]

Readme for wai-cli-0.2.3

[back to package description]

wai-cli Hackage Build Status unlicense

A command line runner for Wai apps (using Warp) with support for:

  • --protocol http --port 8000 TCP sockets
  • --protocol unix --socket /var/run/app/sock UNIX domain sockets
  • --protocol cgi running as a CGI app (the original serverless lambda functions from the 90s)
  • --protocol fastcgi running as a FastCGI app (OPTIONAL! You need to build with the fastcgi cabal flag and you need to have libfcgi (e.g. fcgi-devkit package on FreeBSD) installed)
  • --protocol activate socket activation (systemd-compatible, but not restricted to systemd in any way. see soad for an interesting use of (de)activation!)
  • --protocol (http+tls|unix+tls|activate+tls) --tlskey key.pem --tlscert cert.pem TLS (can be turned off with a cabal flag to avoid compiling the TLS library)
  • --graceful (none|serve-normally|serve-503) graceful shutdown (on TERM signal)
  • --devlogging development logging (from wai-extra)
  • printing a pretty and colorful run message (e.g. Running on http port 3000 with 4 CPUs) (you can replace it with your own, or with nothing)

Extracted from sweetroll and microformats2-parser's demo web app.

Now used in the magicbane framework (which was also extracted from sweetroll).


Add a dependency on wai-cli and write something like this:

{-# LANGUAGE OverloadedStrings #-}
import Web.Scotty
import Network.Wai.Cli
import Data.Monoid (mconcat)

app = scottyApp $ do
  get "/:word" $ do
    beam <- param "word"
    html $ mconcat ["<h1>Scotty, ", beam, " me up!</h1>"]

main = defWaiMain =<< app

Want to use command line args for your application-specific settings? Don't. Use environment variables instead. Possibly with dotenv to load some of them from a file. envy is a really awesome way to read them.


This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.