Skip to content

Instantly share code, notes, and snippets.

@maximebf
Last active December 19, 2015 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximebf/5992791 to your computer and use it in GitHub Desktop.
Save maximebf/5992791 to your computer and use it in GitHub Desktop.
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