Skip to content

Instantly share code, notes, and snippets.

@marfarma
Forked from elimisteve/build
Created June 5, 2013 22:19
Show Gist options
  • Save marfarma/5717806 to your computer and use it in GitHub Desktop.
Save marfarma/5717806 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This is a simple build script and will be executed on your CI system if
# available. Otherwise it will execute while your application is stopped
# before the deploy step. This script gets executed directly, so it
# could be python, php, ruby, etc.
tarball="https://go.googlecode.com/files/go1.0.3.linux-amd64.tar.gz"
# Set GOROOT since we don't use GOROOT_FINAL
mkdir -p $OPENSHIFT_HOMEDIR/app-root/data/go
export GOROOT=$OPENSHIFT_HOMEDIR/app-root/data/go
# GOPATH can be our repo dir.
export GOPATH=$OPENSHIFT_REPO_DIR
# If we do not have a go dir, download and extract dist tarball
if ! test -d "$GOROOT"; then
curl -# $tarball | tar xz -C $(dirname "$GOROOT")
fi
export GO=$GOROOT/bin/go
export GOAPP_SRC_FILE=$OPENSHIFT_REPO_DIR/goapp.go
# Install dependencies
$GO list -f '{{range .Imports}}{{.}}
{{end}}' $GOAPP_SRC_FILE | xargs $GO get
# Build app
$GO build $GOAPP_SRC_FILE
#!/bin/bash
# The logic to start up your application should be put in this
# script. The application will work only if it binds to
# $OPENSHIFT_INTERNAL_IP:8080
nohup ./goapp >> $OPENSHIFT_HOMEDIR/diy-0.1/logs/server.log 2>&1 &
#!/bin/bash
# The logic to stop your application should be put in this script.
kill `ps -ef | grep goapp | grep -v grep | awk '{ print $2 }'` > /dev/null 2>&1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment