pull/10/head
Hunter Long 2018-06-23 19:50:14 -07:00
parent 20ca133eb5
commit 13f584e20b
5 changed files with 30 additions and 10 deletions

View File

@ -17,6 +17,7 @@ services:
- mongodb - mongodb
env: env:
global:
- VERSION=0.18 - VERSION=0.18
matrix: matrix:

View File

@ -1,17 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
mkdir build
APP="statup" APP="statup"
printf "\nUPDATE core SET version='$VERSION';" >> sql/upgrade.sql
rice embed-go rice embed-go
docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
docker build -f Dockerfile -t hunterlong/statup:$VERSION .
docker tag hunterlong/statup:$VERSION hunterlong/statup:latest
docker tag hunterlong/statup:$VERSION hunterlong/statup:$VERSION
docker push hunterlong/statup
mkdir build
xgo -go 1.10.x --targets=darwin/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ xgo -go 1.10.x --targets=darwin/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
xgo -go 1.10.x --targets=darwin/386 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ xgo -go 1.10.x --targets=darwin/386 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
xgo -go 1.10.x --targets=linux/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ xgo -go 1.10.x --targets=linux/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
xgo -go 1.10.x --targets=linux/386 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ xgo -go 1.10.x --targets=linux/386 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
xgo -go 1.10.x --targets=windows/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./ xgo -go 1.10.x --targets=windows/amd64 --dest=build -ldflags="-X main.VERSION=$VERSION" ./
cd build cd build

View File

@ -1,16 +1,16 @@
package main package main
import ( import (
"fmt"
"github.com/hunterlong/statup/types" "github.com/hunterlong/statup/types"
"time" "time"
) )
func LoadDefaultCommunications() { func LoadDefaultCommunications() {
emailer := SelectCommunication(1) emailer := SelectCommunication(1)
fmt.Println(emailer) if emailer.Enabled {
LoadMailer(emailer) LoadMailer(emailer)
go EmailerQueue() go EmailerQueue()
}
} }
func LoadComms() { func LoadComms() {

View File

@ -147,6 +147,7 @@ func mainProcess() {
if err != nil { if err != nil {
throw(err) throw(err)
} }
RunDatabaseUpgrades()
core, err = SelectCore() core, err = SelectCore()
if err != nil { if err != nil {
fmt.Println("Core database was not found, Statup is not setup yet.") fmt.Println("Core database was not found, Statup is not setup yet.")

View File

@ -10,6 +10,7 @@ import (
"strconv" "strconv"
"strings" "strings"
"time" "time"
"upper.io/db.v3"
) )
type DbConfig struct { type DbConfig struct {
@ -28,6 +29,19 @@ type DbConfig struct {
Error error `yaml:"-"` Error error `yaml:"-"`
} }
func RunDatabaseUpgrades() {
fmt.Println("Upgrading Tables...")
upgrade, _ := sqlBox.String("upgrade.sql")
requests := strings.Split(upgrade, ";")
for _, request := range requests {
_, err := dbSession.Exec(db.Raw(request + ";"))
if err != nil {
fmt.Println(err)
}
}
fmt.Println("Database Upgraded")
}
func ProcessSetupHandler(w http.ResponseWriter, r *http.Request) { func ProcessSetupHandler(w http.ResponseWriter, r *http.Request) {
if core != nil { if core != nil {
http.Redirect(w, r, "/", http.StatusSeeOther) http.Redirect(w, r, "/", http.StatusSeeOther)