awful main

  1. awful main
    1. Description
    2. Author
    3. Repository
  2. Requirements
  3. API
    1. Instantiation
    2. Runtime
  4. License
  5. Version History

Description

This module allows you to quickly turn your awful web applications into static executables.

Author

Pietro Cerutti

Repository

https://code.ptrcrt.ch/awful-main

Requirements

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)
  (define (run)
    (define-page
      (main-page-path)
      (lambda ()
        (set-page-title! "awful-main example")
        "Hi, I'm using awful-main!")))
)
; 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)
  (define (run)
    (page-css (string-append (app-root-path) "css.css"))
    (define-page
      (main-page-path)
      (lambda ()
        (set-page-title! "awful-main example")
        "Hi, I'm using awful-main!")))
)

A static executable implementing the website can then be compiled, e.g., with csm via the command line csm -static -program main.

Runtime

The generated main program can be invoked with the following arguments, where <root> is the directory containing the main program.

 -user       user          User to run the website as
 -addr       <ip-addr>     Bind to <ip-addr>              default: 127.0.0.1
 -port       <port-num>    Bind to <port-num>             default: 8080
 -access-log <path>        Enable access log to <path>    default: <root>/access.log
 -debug-log  <path>        Enable debug log to <path>     default: disabled
 -error-log  <path>        Enable error log to <path>     default: <root>/error.log
 -web-root   <path>        Path to the web-root           default: <root>/static
 -dev                      Start awful in dev mode        default: false

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