Home

Awesome

cl-cookieweb

A cookiecutter web template for Common Lisp.

Provides a working toy web app with the Hunchentoot web server, easy-routes, Djula templates, styled with Bulma, based on SQLite, with migrations and an example table definition.

Featuring:

Based on cl-cookieproject: a ready-to-use project template.

Might eventually appear:

Usage

Create a new project. You'll be prompted to provide some basic information about your new project, which will then be auto-generated in the current working directory:

$ pip install cookiecutter
$ cookiecutter https://github.com/vindarel/cl-cookieweb
project_name [cookie-web-project]:
repo_name [cookie-web-project]:
description []: A test project
version [0.0.1]:
year [1984]:
author [CL User]: me
email [me@mail.com]:
username [mme]:
branch [master]:
remote [origin]:
Initialised empty Git repository in /home/vince/bacasable/lisp-projects/cookie-web-project/.git/
Switched to a new branch 'master'

Run it straight away:

$ cd cookie-web-project
$ make run
rlwrap sbcl --load run.lisp
This is SBCL 2.0.10, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
To load "cffi":
  Load 1 ASDF system:
    cffi
; Loading "cffi"
.
To load "cookie-web-project":
  Load 1 ASDF system:
    cookie-web-project
; Loading "cookie-web-project"
cookie-web-project version 0.0.1
Application started on port 4242.
*

You can see the Hello from the main function, and we are given a Lisp REPL.

Build an executable:

$ make build
[…]
; Loading "cookie-web-project"
..................................................
[package cookie-web-project/utils]...............
[package cookie-web-project/models]..............
[package cookie-web-project/web].................
[package cookie-web-project]...

#P"/home/vindarel/projects/cl-cookieweb/cookie-web-project/bin/cookie-web-project"
 ==> Running load hooks.
 ==> Gathering system information.
   -> Will load the following foreign libs on boot:
      (#<DEPLOY:LIBRARY LIBSSL>)
 ==> Deploying files to /home/vindarel/projects/cl-cookieweb/cookie-web-project/bin/
   -> Copying library #<LIBRARY LIBZ>
 ==> Running build hooks.
   -> Closing foreign library #<LIBRARY LIBSSL>.
 ==> Dumping image to /home/vindarel/projects/cl-cookieweb/cookie-web-project/bin/cookie-web-project
[undoing binding stack and other enclosing state... done]
[defragmenting immobile space... 2002+33897+3559+3148+28073+31776 objects... done]
[saving current Lisp image into /home/vindarel/projects/cl-cookieweb/cookie-web-project/bin/cookie-web-project:
writing 0 bytes from the read-only space at 0x20000000
compressed 0 bytes into 8 at level -1
writing 1648 bytes from the static space at 0x20100000
compressed 32768 bytes into 582 at level -1
writing 95027200 bytes from the dynamic space at 0x1000000000
compressed 95027200 bytes into 18359087 at level -1
writing 3043328 bytes from the immobile space at 0x20300000
compressed 3047424 bytes into 795041 at level -1
writing 22947392 bytes from the immobile space at 0x21b00000
compressed 22970368 bytes into 6758085 at level -1
done]

A bin/ directory is created with shared .so libraries:

$ ls bin
cookie-web-project  libz.so

(and when required, you'll find libmagic.so, libosicat.so etc)

Run the binary from the bin/ folder. We can see that Deploy handles loading those shared libraries.

$ ./bin/cookie-web-project
 ==> Performing warm boot.
   -> Runtime directory is /home/vince/projets/cl-cookieweb/cookie-web-project/bin/
   -> Resource directory is /home/vince/projets/cl-cookieweb/cookie-web-project/bin/
 ==> Running boot hooks.
 ==> Reloading foreign libraries.
   -> Loading foreign library #<LIBRARY LIBSSL>.
 ==> Launching application.
 […]
cookie-web-project version 0.0.1
Loading config file config.lisp…
Skipping config file.Starting Hunchentoot on port 4545…
Application started on port 4545.

You can access your app on http://localhost:4545

Systemd

Create a new file in /etc/systemd/system/webcookie.service:

[Unit]
Description=Lisp web project skeleton

[Service]
WorkingDirectory=/home/path/to/cookie-web-project/  # <- directory
ExecStart=/home/path/to/cookie-web-project/bin/cookie-web-project  # <- binary
Type=simple
Restart=on-failure
[Install]
WantedBy=network.target
<!-- WorkingDirectory=/home/vince/projets/cl-cookieweb/cookie-lisp-project/ --> <!-- ExecStart=/home/vince/projets/cl-cookieweb/cookie-lisp-project/bin/cookie-lisp-project -->

Commands:

sudo systemctl start webcookie.service

and also stop and status.

To see logs:

journalctl -u webcookie.service

To start the app on (re)boot:

sudo systemctl enable webcookie.service

If you want to run the app from sources, you can use the command /usr/bin/make run, but tweak run.lisp so that it calls (run) instead of (main), so that the server thread is placed on the foreground. Otherwise, the Lisp process quits instantly and your process is not started.

cookiecutter options

You can use command line options: https://cookiecutter.readthedocs.io/en/1.7.2/advanced/cli_options.html

See also

Other demos and skeletons:

Resources:

Apps:

CHANGELOG


WTFPL

https://github.com/sponsors/vindarel/

<a href='https://ko-fi.com/K3K828W0V' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi2.png?v=2' border='0' alt='buy me a coffee!' title='Is that useful and do you want to see more? Buy Me a Coffee, it is useful, no big income here!' /></a>