-
-
Save elimisteve/4427866 to your computer and use it in GitHub Desktop.
`build`, `start`, and `stop` scripts for getting Go web apps to run on OpenShift. Put these files in the `.openshift/action_hooks/` directory of your app.
This file contains 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
#!/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 |
This file contains 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
#!/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 & |
This file contains 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
#!/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