Skip to content

Commit

Permalink
Merge pull request #1409 from csymonds/mmorgMigration
Browse files Browse the repository at this point in the history
minimega.org: go 112 migration
  • Loading branch information
csymonds committed Mar 24, 2020
2 parents a34c93d + 8850b01 commit 4ff2fc7
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 22 deletions.
5 changes: 2 additions & 3 deletions misc/appengine/app.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
runtime: go
api_version: go1
runtime: go112

handlers:
- url: /.*
script: _go_app
script: auto
secure: always
3 changes: 3 additions & 0 deletions misc/appengine/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module mmorg

go 1.12
49 changes: 31 additions & 18 deletions misc/appengine/update.bash
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#!/bin/bash

# stop on error
set -e

URL=https://github.com/sandia-minimega/minimega.git
ROOT=/data/appengine
ROOT=$(go env GOPATH)

REPO=$ROOT/minimega
TARGET=$ROOT/deploy
SDK=$ROOT/google-cloud-sdk
if [ ! -d $ROOT/src ]; then
mkdir -p $ROOT/src
fi

REPO=$ROOT/src/minimega
TARGET=$ROOT/src/mmorg
SDK=$ROOT/src/google-cloud-sdk

PATH=$PATH:/usr/local/go/bin

Expand All @@ -23,25 +26,35 @@ if [ -d $TARGET ]; then
rm -rf $TARGET
fi

mkdir -p $TARGET/app
mkdir -p $TARGET/src
mkdir $TARGET

# copy appengine
cp $REPO/misc/appengine/app.yaml $TARGET/app/
cp $REPO/src/minidoc/* $TARGET/app/
cp -r $REPO/doc $TARGET/app/
cp $REPO/misc/appengine/app.yaml $TARGET
cp $REPO/misc/appengine/go.mod $TARGET
cp $REPO/src/minidoc/* $TARGET
cp -r $REPO/doc $TARGET

# copy dependencies
cp -r $REPO/src/minicli $TARGET/src/
cp -r $REPO/src/minilog $TARGET/src/
cp -r $REPO/src/present $TARGET/src/
cp -r $REPO/src/ranges $TARGET/src/
mkdir -p $TARGET/src/golang.org/x/net
cp -r $REPO/src/vendor/golang.org/x/net/websocket $TARGET/src/golang.org/x/net/
cp -r $REPO/src/minicli $TARGET
cp -r $REPO/src/minilog $TARGET
cp -r $REPO/src/present $TARGET
cp -r $REPO/src/ranges $TARGET
mkdir -p $TARGET/golang.org/x/net
cp -r $REPO/src/vendor/golang.org/x/net/websocket $TARGET/golang.org/x/net/

# Update include paths
# We need to do this because of the migration to go 112+ requires a specific directory structure
# This structure is not supported by our structure in minimega, so this is a hack to make it work
grep -rl \"minicli\" --exclude-dir minicli --exclude-dir doc $TARGET | xargs sed -i 's/\"minicli\"/\"mmorg\/minicli\"/'
grep -rl \"minilog\" --exclude-dir minilog $TARGET | xargs sed -i 's/\"minilog\"/\"mmorg\/minilog\"/'
grep -rl \"present\" --exclude-dir present $TARGET | xargs sed -i -e '0,/\"present\"/ s/\"present\"/\"mmorg\/present\"/'
grep -rl \"ranges\" --exclude-dir ranges $TARGET | xargs sed -i 's/\"ranges\"/\"mmorg\/ranges\"/'
sed -i 's/\"golang\.org/\"mmorg\/golang\.org/' $TARGET/socket.go


# update tip.minimega.org
cd $TARGET/app
GOPATH=$TARGET $SDK/bin/gcloud app deploy --quiet --project pivotal-sonar-90317 --version 1
cd $TARGET
GOPATH=$ROOT $SDK/bin/gcloud app deploy --verbosity=debug --project pivotal-sonar-90317 --version 1

# update minimega.org
#GOPATH=$TARGET $SDK/bin/gcloud app deploy --quiet --project even-electron-88116 --version 1
10 changes: 9 additions & 1 deletion src/minidoc/minidoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"flag"
log "minilog"
"net/http"
"os"
"present"
"strings"
)
Expand All @@ -33,5 +34,12 @@ func main() {
http.Handle("/socket", NewSocketHandler())
}

log.Fatalln(http.ListenAndServe(*f_server, nil))
port := os.Getenv("PORT")
if port == "" {
port = *f_server
} else {
port = ":" + port
}

log.Fatalln(http.ListenAndServe(port, nil))
}

0 comments on commit 4ff2fc7

Please sign in to comment.