#!/bin/sh

# Copyright (c) 2012-2013 Kaarle Ritvanen
# See LICENSE file for license details

if [ $(basename $0) = run-server.sh ]; then
    export LUA_PATH="./?.lua;./?/init.lua;;"
    PORT=${1:-8000}
    OPTIONS=
    cd $(dirname $0)
else
    PORT=80
    OPTIONS="-d /var/log/acf2.log --pidfile /var/run/acf2.pid"
    cd /usr/share/acf2
fi

exec uwsgi -M --http-socket :$PORT \
    --plugin /usr/lib/uwsgi/lua_plugin.so --lua server.lua \
    --remap-modifier 6:0 \
    --static-map /browser=web --static-index client.html \
    $OPTIONS
