Pelican, compilation avec foreman

Quand on génère son blog avec pelican (ou qu’on lance une simple web app), il est courant de devoir lancer plusieurs process: la compilation de pelican, un serveur web local, une compilation avec sass …

Une solution pour éviter de se retrouver avec un terminal pour chaque process est d’utiliser un fichier Procfile avec foreman. Dans le fichier Procfile on déclare les process de cette façon:

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

En lançant foreman on obtient quelque chose comme ça (avec des couleurs pour chaque 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 est écrit en ruby et installable avec gem install foreman. Pour qui préfère les outils python, il y a honcho, un clone de Foreman.

Commentaires