Skip to content

Instantly share code, notes, and snippets.

View srid's full-sized avatar
🌤️
Never not this moment

Sridhar Ratnakumar srid

🌤️
Never not this moment
View GitHub Profile
@srid
srid / hakyll.md
Last active September 1, 2015 19:25

Using Hakyll with CircleCi and GitHub Pages

[Posted April 24, 2015; restored here for reference]

Today I switched this site from Jekyll to Hakyll, a Haskell library for generating static sites. It is still hosted in GitHub Pages, which only supports Jekyll. Therefore I had to find a Continuous Delivery service (CD) that will perform and connect the "missing piece," the stage that generates the HTML pages — in between a git push and pushing to GitHub pages. Here is how I did it.

The architecture

  1. For CD, we use CircleCI which hooks into the GitHub repo and monitors for any pushes. When a commit or more is pushed it will start the build per the configuration defined in cirle.yml in the repo. The first step runs cabal install which installs the Hakyll dependencies (including pandoc). This step takes a while — and the CircleCI UI provides excellent feedback on
@srid
srid / laundryCoins.hs
Last active August 29, 2015 14:20
laundryCoins.hs
#!/usr/bin/env runhaskell
module Main where
data Coin = Quarter | Loonie deriving (Eq, Show)
type Cents = Int
cents :: Coin -> Cents
cents Quarter = 25
cents Loonie = 100
@srid
srid / jekyll-serve.el
Last active August 29, 2015 14:14
Start local jekyll server (edited by Srid) - http://oremacs.com/2015/02/01/blogging-about-blogging/
(defun jekyll-serve ()
(interactive)
(let* ((default-directory
(if (string-match "_posts/$" default-directory)
(directory-parent default-directory)
default-directory))
(buffer (if (get-buffer "*jekyll*")
(switch-to-buffer "*jekyll*")
(ansi-term "/bin/bash" "jekyll")))
(proc (get-buffer-process buffer)))
@srid
srid / bash_prompt_sh
Last active August 29, 2015 14:01
stackato bash prompt
#!/bin/bash -e
redis_hostport=$(cat /s/etc/kato/redis_uri | cut -d"/" -f3)
redis_host=$(echo $redis_hostport | cut -d: -f1)
redis_port=$(echo $redis_hostport | cut -d: -f2)
redis_cli="redis-cli -h ${redis_host} -p ${redis_port}"
user=$(whoami)
endpoint=$(timeout 0.1 $redis_cli get cluster | json endpoint)
ipaddr=$(timeout 0.1 /sbin/ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}')
roles=$(timeout 0.1 $redis_cli get node | json "[\"${ipaddr}\"]" | json roles | json -ak | paste -sd "," -)
// read-only registry API server
// TODO:
// * directly read from the .tar file (will break martini.Static)
// * UX friendly error handling
package main
import (
"encoding/json"
#!/bin/bash -ex
# Wrapper for 'docker save' fixing,
# https://github.com/dotcloud/docker/issues/3877
# In addition: this script will always save exactly one image (possibly
# multiple tags).
IMAGE=$1
TARGET=$2
NAME=`echo $IMAGE | awk -F':' '{print $1}'`
ID=`docker inspect $IMAGE | python -c "import sys,json; print json.load(sys.stdin)[0]['id']"`
// GetNameServers returns nameservers configured on the host.
func GetNameServers() ([]string, error) {
resolvFile := "/etc/resolv.conf"
f, err := os.Open(resolvFile)
if err != nil {
return nil, err
}
defer f.Close()
+ sudo docker run -e REDIS_PROVIDER_URL=redis://[email protected]:6379 -e POSTGRES_HOST=172.17.0.58 -e POSTGRES_PORT=5432 -v /home/srid/code/discourse/data/assets:/discourse/public/assets -v /discourse/public srid/discourse /discourse/init.sh 'bundle exec rails s'
lxc-start: No such file or directory - failed to mount '/home/srid/code/discourse/data/assets' on '/usr/lib/x86_64-linux-gnu/lxc///discourse/public/assets'
lxc-start: failed to setup the mount entries for '2e05edd484a05ced1f47a927a6093cecd7c098db42fefd6cfec488e8c4ca3009'
lxc-start: failed to setup the container
lxc-start: invalid sequence number 1. expected 2
lxc-start: failed to spawn '2e05edd484a05ced1f47a927a6093cecd7c098db42fefd6cfec488e8c4ca3009'
Request PUT, application/json: https://api.stackato-nightly.activestate.com/apps/env -query {
"env" : ["FOO=bar"],
"instances" : "1",
"meta" : {
"console" : "null",
"created" : "1368826688", "debug" : "null",
"version" : "4" }, "name" : "env",
"resources" : {
"disk" : "2048",
"fds" : "256",
diff --git a/deploy/app-logs.rst b/deploy/app-logs.rst
index 0c5ebe3..228c113 100644 (file)
--- a/deploy/app-logs.rst
+++ b/deploy/app-logs.rst
@@ -19,6 +19,17 @@ filtered. Application log streams can be accessed via:
Information on system logs for Stackato itself and log aggregation
settings can be found in the :ref:`Log Aggregation <logging>` documentation.
+Log streams are tailed output from actual log files in each application
+container, generally found in the */app/logs/* directory. These files