Last active
December 19, 2015 17:38
-
-
Save maximebf/5992791 to your computer and use it in GitHub Desktop.
Fabfile to publish jekyll blogs with supervisor and nginx configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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