Closed EuAndreh closed 6 years ago
I would recommend using supervisor to keep the Lisp image running on, say, port 8000; and Nginx acting as a reverse proxy with something like the following configuration:
server {
listen 80;
location / {
proxy_pass http://0.0.0.0:8000;
charset utf-8;
}
}
I personally just use something like this in a screen session:
sbcl --eval '(ql:quickload :my-app)' --eval '(my-app:start :port 12345)'
and Apache to ProxyPass to it:
ServerName example.com
ProxyPass / http://localhost:12345
From there its just a small bit of work to write a shell script to act as an init daemon and auto start on boot.
The way to deploy a web application is not established yet. Though I write the latest method I'm using for my company, it could be changed in the future.
First of all, I use Roswell to install SBCL on servers. It provides a command ros
to invoke SBCL.
And I wrote a Roswell script bin/clackup which calls clack:clackup
for app.lisp. The app.lisp must be a Common Lisp file which returns a Clack app at the end.
You can use the script like this:
$ cd /path/to/project
$ APP_ENV=production clackup app.lisp --server hunchentoot --port 9090 --debug nil
Usually, I use the command with Qlot for fixing versions of libraries. Qlot also provides a shell script named qlot.
$ cd /path/to/project
$ qlot install
$ APP_ENV=production qlot exec clackup app.lisp --server hunchentoot --port 9090 --debug nil
I don't recommend to run the server on 80 port directly because some servers (ex. Hunchentoot) are weak for DoS attack and Slowloris attack. Using nginx as a reverse proxy for it would be better. You can serve static files from it and it reduces the load of your app server.
If you'd like hot-deployment, a certain tool to do it like Server::Starter would help.
And make sure that your application will be restarted if the process dies unexpectedly with a process monitor tool like daemontools or supervisor.
If you'd like to deploy without Roswell, you can run it by a one-liner as ghost is saying.
One thing you should know is threading.
It starts a new thread if the SBCL supports threads and the process ends right away. Use :use-thread nil
option for the situation.
Also, is it possible to clackup
to 0.0.0.0
instead of localhost
?
It depends on which handler you choose. Currently, Woo is the only one which accepts :address
keyword and it can be specified at --address
from clackup
command.
0.0.0.0
is the default value, though.
Cool, thanks.
I am curious @fukamachi, how has your deployment process changed over the years for CL apps? Your bin/clackup link is broken. Thanks.
What's your setup for deploying clack apps?
I'm writing an app and can't figure out how to deploy it, and I need just a few tips. Any help?