Skip to content

Instantly share code, notes, and snippets.

@maximebf maximebf/fabfile.py
Last active Dec 19, 2015

Embed
What would you like to do?
Fabfile to publish jekyll blogs with supervisor and nginx configuration
from fabric.api import task, env, execute, local
env.build_path = '/tmp/jekyll'
env.publish_path = '~/sites'
@task
def serve(future='yes', drafts='yes', port=4000):
flags = []
if future == 'yes':
flags.append("--future")
if drafts == 'yes':
flags.append('--drafts')
local('/usr/local/bin/jekyll serve --port %s --trace --watch %s --destination %s' % (port, ' '.join(flags), env.build_path))
@task
def build():
local("/usr/local/bin/jekyll build --destination %s" % env.build_path)
@task
def publish():
execute(build)
local('rsync -rlpzvi --delete %s/ %s' % (env.build_path, env.publish_path))
server {
listen 80;
server_name example.com;
root /path/to/publish/path/for/example.com;
access_log /home/logs/nginx/example.access.log;
error_log /home/logs/nginx/errors.log;
try_files $uri.html $uri/ =404;
location /assets {
access_log off;
expires max;
}
}
server {
listen 80;
server_name draft.example.com;
root /path/to/publish/path/for/draft.example.com;
access_log off;
error_log /home/logs/nginx/errors.log;
auth_basic "Restricted access";
auth_basic_user_file /etc/nginx/users.conf;
try_files $uri.html $uri/ =404;
}
server {
listen 80;
server_name www.example.com;
rewrite ^/(.*) http://example.com/$1 permanent;
}
[program:draftjekyll]
directory=/path/to/Dropbox/MyWebsite
command=jekyll build --watch --future --drafts --destination /path/to/publish/path/for/draft.mywebsite.com
autostart=true
autorestart=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.