mirror of https://github.com/statping/statping
errs
parent
473419fefb
commit
ca53f6c9cd
2
.env
2
.env
|
@ -2,7 +2,7 @@
|
||||||
## Database Information #
|
## Database Information #
|
||||||
###########################
|
###########################
|
||||||
DB_CONNECTION=postgres
|
DB_CONNECTION=postgres
|
||||||
DB_HOST=localhost
|
DB_HOST=0.0.0.0
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
DB_USER=root
|
DB_USER=root
|
||||||
DB_PASS=password123
|
DB_PASS=password123
|
||||||
|
|
|
@ -65,9 +65,9 @@ before_script:
|
||||||
- go get github.com/GeertJohan/go.rice
|
- go get github.com/GeertJohan/go.rice
|
||||||
- go get github.com/GeertJohan/go.rice/rice
|
- go get github.com/GeertJohan/go.rice/rice
|
||||||
- go get
|
- go get
|
||||||
- go install
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then /bin/bash -c .travis/compile.sh; fi
|
||||||
- go test -v -covermode=count -coverprofile=coverage.out && $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $COVERALLS
|
- go test -v -covermode=count -coverprofile=coverage.out && $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $COVERALLS
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
|
|
|
@ -3,28 +3,6 @@
|
||||||
APP="statup"
|
APP="statup"
|
||||||
REPO="hunterlong/statup"
|
REPO="hunterlong/statup"
|
||||||
|
|
||||||
# COMPILE BOOTSTRAP
|
|
||||||
rm -rf bootstrap
|
|
||||||
git clone https://github.com/twbs/bootstrap.git
|
|
||||||
cd bootstrap
|
|
||||||
npm install
|
|
||||||
rm -f scss/_variables.scss
|
|
||||||
cp ../html/scss/_variables.scss scss/_variables.scss
|
|
||||||
npm run dist
|
|
||||||
mv dist/css/bootstrap.min.css ../html/css/bootstrap.min.css
|
|
||||||
cd ../
|
|
||||||
rm -rf bootstrap
|
|
||||||
|
|
||||||
# RENDERING CSS
|
|
||||||
#gem install sass
|
|
||||||
sass html/scss/base.scss html/css/base.css
|
|
||||||
|
|
||||||
# MIGRATION SQL FILE FOR CURRENT VERSION
|
|
||||||
printf "UPDATE core SET version='$VERSION';\n" >> sql/upgrade.sql
|
|
||||||
|
|
||||||
# COMPILE SRC INTO BIN
|
|
||||||
rice embed-go
|
|
||||||
|
|
||||||
# BUILD STATUP GOLANG BINS
|
# BUILD STATUP GOLANG BINS
|
||||||
mkdir build
|
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" ./
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# COMPILE BOOTSTRAP
|
||||||
|
rm -rf bootstrap
|
||||||
|
git clone https://github.com/twbs/bootstrap.git
|
||||||
|
cd bootstrap
|
||||||
|
npm install
|
||||||
|
rm -f scss/_variables.scss
|
||||||
|
cp ../html/scss/_variables.scss scss/_variables.scss
|
||||||
|
npm run dist
|
||||||
|
mv dist/css/bootstrap.min.css ../html/css/bootstrap.min.css
|
||||||
|
cd ../
|
||||||
|
rm -rf bootstrap
|
||||||
|
|
||||||
|
# RENDERING CSS
|
||||||
|
gem install sass
|
||||||
|
sass html/scss/base.scss html/css/base.css
|
||||||
|
|
||||||
|
# MIGRATION SQL FILE FOR CURRENT VERSION
|
||||||
|
printf "UPDATE core SET version='$VERSION';\n" >> sql/upgrade.sql
|
||||||
|
|
||||||
|
# COMPILE SRC INTO BIN
|
||||||
|
rice embed-go
|
||||||
|
|
||||||
|
go install
|
|
@ -8,18 +8,17 @@ RUN wget https://github.com/hunterlong/statup/releases/download/$VERSION/statup-
|
||||||
chmod +x statup && \
|
chmod +x statup && \
|
||||||
mv statup /usr/local/bin/statup
|
mv statup /usr/local/bin/statup
|
||||||
|
|
||||||
#COPY build/statup /usr/local/bin/statup
|
|
||||||
#RUN chmod +x /usr/local/bin/statup
|
|
||||||
|
|
||||||
RUN wget https://assets.statup.io/sass && \
|
RUN wget https://assets.statup.io/sass && \
|
||||||
chmod +x sass && \
|
chmod +x sass && \
|
||||||
mv sass /usr/local/bin/sass
|
mv sass /usr/local/bin/sass
|
||||||
|
|
||||||
|
ENV IS_DOCKER=true
|
||||||
ENV SASS=/usr/local/bin/sass
|
ENV SASS=/usr/local/bin/sass
|
||||||
ENV CMD_FILE=/usr/bin/cmd
|
ENV CMD_FILE=/usr/bin/cmd
|
||||||
|
ENV USE_ASSETS=true
|
||||||
|
|
||||||
RUN printf "#!/usr/bin/env sh\n\$1\n" > $CMD_FILE && \
|
RUN printf "#!/usr/bin/env sh\n\$1\n" > $CMD_FILE && \
|
||||||
chmod +x $CMD_FILE
|
chmod +x $CMD_FILE
|
||||||
ENV USE_ASSETS=true
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
VOLUME /app
|
VOLUME /app
|
||||||
|
|
10
cli.go
10
cli.go
|
@ -17,9 +17,13 @@ func CatchCLI(args []string) {
|
||||||
case "sass":
|
case "sass":
|
||||||
CompileSASS()
|
CompileSASS()
|
||||||
case "export":
|
case "export":
|
||||||
|
var err error
|
||||||
fmt.Printf("Statup v%v Exporting Static 'index.html' page...\n", VERSION)
|
fmt.Printf("Statup v%v Exporting Static 'index.html' page...\n", VERSION)
|
||||||
RenderBoxes()
|
RenderBoxes()
|
||||||
configs, _ = LoadConfig()
|
configs, err = LoadConfig()
|
||||||
|
if err != nil {
|
||||||
|
logger(3, "config.yml file not found")
|
||||||
|
}
|
||||||
setupMode = true
|
setupMode = true
|
||||||
mainProcess()
|
mainProcess()
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
|
@ -32,12 +36,10 @@ func CatchCLI(args []string) {
|
||||||
fmt.Println("Sorry updating isn't available yet!")
|
fmt.Println("Sorry updating isn't available yet!")
|
||||||
case "run":
|
case "run":
|
||||||
fmt.Println("Running 1 time and saving to database...")
|
fmt.Println("Running 1 time and saving to database...")
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
configs, err = LoadConfig()
|
configs, err = LoadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("config.yml file not found")
|
logger(3, "config.yml file not found")
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
err = DbConnection(configs.Connection)
|
err = DbConnection(configs.Connection)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
27
main.go
27
main.go
|
@ -16,6 +16,7 @@ import (
|
||||||
plg "plugin"
|
plg "plugin"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"github.com/fatih/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -94,12 +95,34 @@ func DownloadFile(filepath string, url string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
LoadDotEnvs()
|
||||||
|
}
|
||||||
|
|
||||||
|
func LoadDotEnvs() {
|
||||||
err := godotenv.Load()
|
err := godotenv.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error loading .env file")
|
fmt.Println("Error loading .env file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func logger(level int, err interface{}) {
|
||||||
|
switch level {
|
||||||
|
case 3:
|
||||||
|
color.Red("ERROR: %v\n", err)
|
||||||
|
os.Exit(2)
|
||||||
|
case 2:
|
||||||
|
color.Yellow("WARNING: %v\n", err)
|
||||||
|
case 1:
|
||||||
|
color.Blue("INFO: %v\n", err)
|
||||||
|
case 0:
|
||||||
|
color.White("%v\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) >= 2 {
|
if len(os.Args) >= 2 {
|
||||||
CatchCLI(os.Args)
|
CatchCLI(os.Args)
|
||||||
|
@ -113,7 +136,7 @@ func main() {
|
||||||
|
|
||||||
configs, err = LoadConfig()
|
configs, err = LoadConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("config.yml file not found - starting in setup mode")
|
logger(1, "config.yml file not found - starting in setup mode")
|
||||||
setupMode = true
|
setupMode = true
|
||||||
RunHTTPServer()
|
RunHTTPServer()
|
||||||
}
|
}
|
||||||
|
@ -134,7 +157,7 @@ func mainProcess() {
|
||||||
RunDatabaseUpgrades()
|
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.")
|
logger(1, "Core database was not found, Statup is not setup yet.")
|
||||||
RunHTTPServer()
|
RunHTTPServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
main_test.go
13
main_test.go
|
@ -4,13 +4,14 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"github.com/rendon/testcli"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInit(t *testing.T) {
|
func TestInit(t *testing.T) {
|
||||||
RenderBoxes()
|
RenderBoxes()
|
||||||
os.Remove("./statup.db")
|
os.Remove("./statup.db")
|
||||||
Router()
|
Router()
|
||||||
|
LoadDotEnvs()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMySQLMakeConfig(t *testing.T) {
|
func TestMySQLMakeConfig(t *testing.T) {
|
||||||
|
@ -236,9 +237,9 @@ func TestService_LimitedHits(t *testing.T) {
|
||||||
assert.Equal(t, 23, len(hits))
|
assert.Equal(t, 23, len(hits))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test(t *testing.T) {
|
func TestLitecoinWalletsCommand(t *testing.T) {
|
||||||
var err error
|
c := testcli.Command("statup", "version")
|
||||||
configs, err = LoadConfig()
|
c.Run()
|
||||||
assert.Nil(t, err)
|
t.Log(c.Stdout())
|
||||||
time.Sleep(2 * time.Second)
|
assert.True(t, c.StdoutContains("0 | Address: LS1QwoS72uYBHfCVmyD1oT75BAsh2iCqgP"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue