Skip to content

Instantly share code, notes, and snippets.

@dz0ny
Forked from elimisteve/build
Created July 2, 2013 10:58
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 dz0ny/5908426 to your computer and use it in GitHub Desktop.
Save dz0ny/5908426 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.1.1.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