Pelican, compilation with foreman

When generating a blog with pelican (or running a simple web app), it is common to have to launch multiple processes: the pelican compilation, a local web server, sass compilation … Using a Procfile with foreman is a simple way to solve this. A Procfile is a text file in which you declare the processes that you want to run:

web: python -m SimpleHTTPServer
build: python -u `which pelican` -r -s devsettings.py
css: sass --watch theme/static/css/main.scss:theme/static/css/style.min.css --style compressed

Starting foreman will give something like this (with colors for each process):

> foreman start
00:36:17 web.1   | started with pid 6742
00:36:17 build.1 | started with pid 6743
00:36:17 css.1   | started with pid 6744
00:36:18 build.1 |   --- AutoReload Mode: Monitoring `content`, `theme` and `settings` for changes. ---
00:36:18 build.1 |
00:36:18 build.1 | -> Modified: content, theme, settings. re-generating...
00:36:20 build.1 | WARNING: AUTHOR_SAVE_AS is set to False
00:36:20 build.1 | Done: Processed 77 articles and 2 pages in 2.47 seconds.
00:36:33 web.1   | 127.0.0.1 - - [18/May/2013 00:36:33] "GET /log/ HTTP/1.1" 200 -
00:36:33 web.1   | 127.0.0.1 - - [18/May/2013 00:36:33] "GET /log/theme/css/style.min.css?9c8f03b HTTP/1.1" 200 -
00:36:33 web.1   | 127.0.0.1 - - [18/May/2013 00:36:33] code 404, message File not found
00:36:33 web.1   | 127.0.0.1 - - [18/May/2013 00:36:33] "GET /favicon.ico HTTP/1.1" 404 -
00:36:57 build.1 |
00:36:57 build.1 | -> Modified: theme. re-generating...
00:36:58 css.1   | >>> Sass is watching for changes. Press Ctrl-C to stop.
00:36:58 css.1   | >>> Change detected to: /home/simon/Web/saimon.org/pelican-inuk/static/css/main.scss
00:36:58 css.1   |   overwrite theme/static/css/style.min.css
00:37:00 build.1 | WARNING: AUTHOR_SAVE_AS is set to False
00:37:00 build.1 | Done: Processed 77 articles and 2 pages in 2.29 seconds.
00:38:10 build.1 |
00:38:10 build.1 | -> Modified: content. re-generating...
00:38:12 build.1 | WARNING: AUTHOR_SAVE_AS is set to False
00:38:12 build.1 | Done: Processed 77 articles and 2 pages in 2.31 seconds.

foreman is written in ruby and can be installed with gem install foreman. For those who prefer python tools, honcho is a python clone of Foreman.

Commentaires