There were a number of things that were unfinished since my previous post. Jekyll bootstrap provides the ability to add a comments section (courtesy of Disqus) as well as the ability to track page statistics using Google analytics. However, in order to make any use of these features, you may want to create a Google analytics account as well as a Disqus account, while setting up the _config.yml file accordingly. In addition, in order to enable Google analytics and Disqus on your blog, you will want to run the Jekyll build as follows (I combine the jekyll build and the S3 website upload in 1 single command).
JEKYLL_ENV=production jekyll build && s3_website push
In addition, I have been using JGit as a means of setting up a private git repository for blog postings. The private git repo is hosted on an S3 bucket. The following blog discusses how JGit can be used to leverage an S3 bucket as a private Git repository.
Now, I have separated the blog postings from Jekyll itself. I can now carry around a local copy of the blog content on any device while using an EC2 instance to actually deploy the blog. The EC2 instance starts with a shutdown timer of 55 minutes so that it can only run for at most 1 hour. The following is contained with /etc/rc.local.
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. /sbin/shutdown -h +55 touch /var/lock/subsys/local
Any time I wish to push content, I run an (ugly) script which looks like the following. This basically gets the instance responsible for deployment, determines if it is off, turns on the instance and waits until it is active, then proceeds to run the deployment script via ssh.
#!/bin/sh INSTANCE_ID=<instance id> INSTANCE_STATUS=`aws --profile atokhy ec2 start-instances --instance-ids $INSTANCE_ID --query 'StartingInstances.CurrentState.Name' --output text` while [ "X$INSTANCE_STATUS" != "Xrunning" ]; do sleep 60 INSTANCE_STATUS=`aws --profile atokhy ec2 describe-instances --instance-id $INSTANCE_ID --query 'Reservations.Instances.[State.Name]' --output text` done INSTANCE_IP_ADDRESS=`aws --profile atokhy ec2 describe-instances --instance-id $INSTANCE_ID --query 'Reservations.Instances.[PublicIpAddress]' --output text` ssh ec2-user@"$INSTANCE_IP_ADDRESS" '$HOME/bin/deploy'
The deploy script on the EC2 instance looks like the following.
#!/bin/bash cd <path to _posts directory> $HOME/bin/jgit fetch git merge cd <path to Jekyll directory> JEKYLL_ENV=production jekyll build && s3_website push cd -
This merges the changes to a local copy while deploying to the site hosted on S3.
Finally, you may want to ask, why go through all this trouble? Why overcomplicate serving a static page. I could have just as well set up Jekyll on my host.
In this case, all I need is a device that can edit text files and can use git. No need to have any tools installed, as all of them reside on the t2.micro instance dedicated for this task.
Hopefully, this should be the last post on the subject of setting up jekyll bootstrap unless there are any edits to the look and feel of the site. My next post will focus on setting up Xen on Debian Jessie (8.0).