MyNixOS website logo
Description

Command line runner for Wai apps (using Warp) with TLS, CGI, socket activation & graceful shutdown.

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://github.com/unrelentingtech/soad for a more interesting (and not linux-only) thing than what systemd does), and graceful shutdown (on TERM signal).

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

Usage

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.

License

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

Metadata

Version

0.2.3

License

publicDomain

Platforms (75)

    Darwin
    FreeBSD 13
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd13
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd13
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows