== awful-main [[toc:]] === Description This module allows you to quickly turn your [[https://wiki.call-cc.org/eggref/5/awful|awful]] web applications into static executables. === Author Pietro Cerutti === Repository [[https://code.ptrcrt.ch/awful-main|https://code.ptrcrt.ch/awful-main]] === Requirements * [[https://wiki.call-cc.org/eggref/5/awful|awful]] * [[https://wiki.call-cc.org/eggref/5/spiffy|spiffy]] === API ==== Instantiation This module exposes a single functor, {{awful main}}, which is instantiated to produce a main module that can be compiled into a static executable. This can be done using two separate modules: ; site.scm (module site (run) (import scheme awful (chicken base) (chicken format)) (define (run args) (let ((name (member "name" args))) (unless name (error "Required argument: name")) (define-page (main-page-path) (lambda () (set-page-title! "awful-main example") (sprintf "Hi, ~A, I'm using awful-main" (cadr name))))))) [lang:scheme] ; main.scm (import (awful main) site) (module main = ((awful main) site)) ... or with a single in-line functor instantiation: ; main.scm (import (awful main)) (module main = (awful main) (import scheme awful (chicken base) (chicken format)) (define (run args) (let ((name (member "name" args))) (unless name (error "Required argument: name")) (define-page (main-page-path) (lambda () (set-page-title! "awful-main example") (sprintf "Hi, ~A, I'm using awful-main" (cadr name))))))) A static executable implementing the website can then be compiled, e.g., via the command line {{csm -static -program main}}. ==== Runtime The generated {{main}} program can be invoked with the following arguments, where {{}} is the directory containing the {{main}} program. -user user User to run the website as -addr Bind to default: 127.0.0.1 -port Bind to default: 8080 -access-log Enable access log to default: /access.log -debug-log Enable debug log to default: disabled -error-log Enable error log to default: /error.log -web-root Path to the web-root default: /static -dev Start awful in dev mode default: false -args Pass additional arguments to `run` If {{-args}} is specified, any additional arguments present on the command line are passed to the {{run}} function in the implementation. Example: ./main --port=9092 --web-root=./static --args name Joe For a minimal working example, see the [[https://code.ptrcrt.ch/awful-main/dir?ci=trunk&name=example|example]] directory in the source code repository. === License Copyright (c) Pietro Cerutti All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. === Version History * 0.3.0 - drop dependency on {{define-options}} to reduce build time of web apps * 0.2.0 - support passing arguments to {{run}} via the {{-args}} switch * 0.1.0 - initial release