mirror of https://github.com/statping/statping
Merge branch 'master' into bugfix-522
commit
d1073ca254
|
@ -1,17 +1,25 @@
|
||||||
name: Dev Release
|
name: Push Request Testing
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- dev
|
- '*' # matches every branch
|
||||||
|
- '*/*' # matches every branch containing a single '/'
|
||||||
|
- '!master' # excludes master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
compile:
|
compile:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- uses: actions/setup-go@v2
|
||||||
uses: actions/setup-go@v1
|
|
||||||
with:
|
with:
|
||||||
go-version: '1.14.x'
|
go-version: '1.14.2'
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: '10.x'
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Add GOBIN to PATH
|
- name: Add GOBIN to PATH
|
||||||
run: |
|
run: |
|
||||||
|
@ -19,40 +27,14 @@ jobs:
|
||||||
echo ::set-env name=VERSION::$(cat version.txt)
|
echo ::set-env name=VERSION::$(cat version.txt)
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install Node
|
|
||||||
uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: '10.x'
|
|
||||||
|
|
||||||
- name: Install Global Dependencies
|
- name: Install Global Dependencies
|
||||||
run: npm install -g yarn sass cross-env
|
run: npm install -g yarn sass cross-env
|
||||||
|
|
||||||
- name: Checkout Statping Repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- uses: actions/cache@v1
|
|
||||||
id: nodecache
|
|
||||||
with:
|
|
||||||
path: ./frontend/node_modules
|
|
||||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-node-
|
|
||||||
|
|
||||||
- name: Download Frontend Dependencies
|
- name: Download Frontend Dependencies
|
||||||
if: steps.nodecache.outputs.cache-hit != 'true'
|
if: steps.nodecache.outputs.cache-hit != 'true'
|
||||||
working-directory: ./frontend
|
working-directory: ./frontend
|
||||||
run: yarn
|
run: yarn
|
||||||
|
|
||||||
- uses: actions/cache@v1
|
|
||||||
id: golangcache
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/go/pkg/mod
|
|
||||||
~/go/bin
|
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go-
|
|
||||||
|
|
||||||
- name: Download Go mods
|
- name: Download Go mods
|
||||||
if: steps.golangcache.outputs.cache-hit != 'true'
|
if: steps.golangcache.outputs.cache-hit != 'true'
|
||||||
run: |
|
run: |
|
||||||
|
@ -61,25 +43,49 @@ jobs:
|
||||||
make test-deps
|
make test-deps
|
||||||
|
|
||||||
- name: Build Frontend Statping
|
- name: Build Frontend Statping
|
||||||
run: make clean frontend-build
|
run: make clean compile
|
||||||
|
|
||||||
- name: Upload Compiled Frontend
|
- name: Upload Compiled Frontend (rice-box.go)
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: static-frontend
|
name: static-rice-box
|
||||||
path: /home/runner/work/statping/statping/source/dist
|
path: ./source
|
||||||
|
|
||||||
test:
|
pr-test:
|
||||||
needs: compile
|
needs: compile
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
|
||||||
- name: Checkout Statping Repo
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Install Go
|
services:
|
||||||
uses: actions/setup-go@v1
|
postgres:
|
||||||
|
image: postgres:10.8
|
||||||
|
env:
|
||||||
|
POSTGRES_USER: root
|
||||||
|
POSTGRES_PASSWORD: password123
|
||||||
|
POSTGRES_DB: statping
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
image: mysql:5.7
|
||||||
|
env:
|
||||||
|
MYSQL_ROOT_PASSWORD: password123
|
||||||
|
MYSQL_DATABASE: statping
|
||||||
|
ports:
|
||||||
|
- 3306:3306
|
||||||
|
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: '1.14.x'
|
go-version: '1.14.2'
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: '10.x'
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Global Dependencies
|
||||||
|
run: npm install -g yarn sass newman cross-env wait-on @sentry/cli
|
||||||
|
|
||||||
- name: Setting ENV's
|
- name: Setting ENV's
|
||||||
run: |
|
run: |
|
||||||
|
@ -88,75 +94,73 @@ jobs:
|
||||||
echo ::set-env name=VERSION::$(cat version.txt)
|
echo ::set-env name=VERSION::$(cat version.txt)
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install Node
|
- name: Download Compiled Frontend (rice-box.go)
|
||||||
uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: '10.x'
|
|
||||||
|
|
||||||
- name: Install Global Dependencies
|
|
||||||
run: npm install -g yarn sass newman cross-env wait-on @sentry/cli
|
|
||||||
|
|
||||||
- uses: actions/cache@v1
|
|
||||||
id: golangcache
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/go/pkg/mod
|
|
||||||
~/go/bin
|
|
||||||
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-go-
|
|
||||||
|
|
||||||
- name: Download Go mods
|
|
||||||
if: steps.golangcache.outputs.cache-hit != 'true'
|
|
||||||
run: |
|
|
||||||
go mod download
|
|
||||||
go mod verify
|
|
||||||
make test-deps
|
|
||||||
|
|
||||||
- name: Download Compiled Frontend
|
|
||||||
uses: actions/download-artifact@v1
|
uses: actions/download-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: static-frontend
|
name: static-rice-box
|
||||||
path: /home/runner/work/statping/statping/source/dist
|
path: ./source
|
||||||
|
|
||||||
- name: Install Statping
|
- name: Install Statping
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ env.VERSION }}
|
VERSION: ${{ env.VERSION }}
|
||||||
run: |
|
run: |
|
||||||
make build
|
make build
|
||||||
chmod +x statping
|
chmod +x statping
|
||||||
mv statping $(go env GOPATH)/bin/
|
mv statping $(go env GOPATH)/bin/
|
||||||
|
|
||||||
- name: Go Tests
|
- name: Go Tests
|
||||||
run: SASS=`which sass` go test -v -covermode=count -coverprofile=coverage.out -p=1 ./...
|
run: |
|
||||||
|
go get gotest.tools/gotestsum
|
||||||
|
gotestsum --no-summary=skipped --format dots -- -covermode=count -coverprofile=coverage.out -p=1 ./...
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ env.VERSION }}
|
VERSION: ${{ env.VERSION }}
|
||||||
DB_CONN: sqlite3
|
DB_CONN: sqlite3
|
||||||
STATPING_DIR: /home/runner/work/statping/statping
|
STATPING_DIR: ${{ github.workspace }}
|
||||||
API_KEY: demopassword123
|
API_KEY: demopassword123
|
||||||
DISABLE_LOGS: true
|
DISABLE_LOGS: true
|
||||||
ALLOW_REPORTS: true
|
ALLOW_REPORTS: true
|
||||||
COVERALLS: ${{ secrets.COVERALLS }}
|
PUSH_REQUEST: true
|
||||||
DISCORD_URL: ${{ secrets.DISCORD_URL }}
|
|
||||||
EMAIL_HOST: ${{ secrets.EMAIL_HOST }}
|
|
||||||
EMAIL_USER: ${{ secrets.EMAIL_USER }}
|
|
||||||
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
|
|
||||||
EMAIL_OUTGOING: ${{ secrets.EMAIL_OUTGOING }}
|
|
||||||
EMAIL_SEND_TO: ${{ secrets.EMAIL_SEND_TO }}
|
|
||||||
EMAIL_PORT: ${{ secrets.EMAIL_PORT }}
|
|
||||||
MOBILE_ID: ${{ secrets.MOBILE_ID }}
|
|
||||||
MOBILE_NUMBER: ${{ secrets.MOBILE_NUMBER }}
|
|
||||||
PUSHOVER_TOKEN: ${{ secrets.PUSHOVER_TOKEN }}
|
|
||||||
PUSHOVER_API: ${{ secrets.PUSHOVER_API }}
|
|
||||||
SLACK_URL: ${{ secrets.SLACK_URL }}
|
|
||||||
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
|
|
||||||
TELEGRAM_CHANNEL: ${{ secrets.TELEGRAM_CHANNEL }}
|
|
||||||
TWILIO_SID: ${{ secrets.TWILIO_SID }}
|
|
||||||
TWILIO_SECRET: ${{ secrets.TWILIO_SECRET }}
|
|
||||||
TWILIO_FROM: ${{ secrets.TWILIO_FROM }}
|
|
||||||
TWILIO_TO: ${{ secrets.TWILIO_TO }}
|
|
||||||
|
|
||||||
- name: Coveralls Testing Coverage
|
pr-test-postman:
|
||||||
run: goveralls -coverprofile=coverage.out -repotoken $COVERALLS
|
needs: compile
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: '1.14.2'
|
||||||
|
|
||||||
|
- name: Setting ENV's
|
||||||
|
run: |
|
||||||
|
echo "::add-path::$(go env GOPATH)/bin"
|
||||||
|
echo "::add-path::/opt/hostedtoolcache/node/10.20.1/x64/bin"
|
||||||
|
echo ::set-env name=VERSION::$(cat version.txt)
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Download Compiled Frontend (rice-box.go)
|
||||||
|
uses: actions/download-artifact@v1
|
||||||
|
with:
|
||||||
|
name: static-rice-box
|
||||||
|
path: ./source
|
||||||
|
|
||||||
|
- name: Install Statping
|
||||||
env:
|
env:
|
||||||
COVERALLS: ${{ secrets.COVERALLS }}
|
VERSION: ${{ env.VERSION }}
|
||||||
|
run: |
|
||||||
|
make build
|
||||||
|
chmod +x statping
|
||||||
|
mv statping $(go env GOPATH)/bin/
|
||||||
|
|
||||||
|
- name: Run Statping
|
||||||
|
run: |
|
||||||
|
API_SECRET=demosecret123 statping --port=8080 > /dev/null &
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
- name: Postman Tests
|
||||||
|
uses: matt-ball/newman-action@master
|
||||||
|
with:
|
||||||
|
postmanApiKey: ${{ secrets.POSTMAN_API }}
|
||||||
|
collection: ./dev/postman.json
|
||||||
|
environment: ./dev/postman_environment.json
|
||||||
|
timeoutRequest: 15000
|
||||||
|
delayRequest: 1000
|
||||||
|
|
|
@ -266,7 +266,9 @@ jobs:
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ env.VERSION }}
|
VERSION: ${{ env.VERSION }}
|
||||||
COMMIT: $GITHUB_SHA
|
COMMIT: $GITHUB_SHA
|
||||||
run: make build-linux
|
run: |
|
||||||
|
go env
|
||||||
|
make build-linux
|
||||||
|
|
||||||
- name: Upload Linux Builds
|
- name: Upload Linux Builds
|
||||||
uses: actions/upload-artifact@v1
|
uses: actions/upload-artifact@v1
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
# 0.90.33 (04-24-2020)
|
||||||
|
- Fixed config loading method
|
||||||
|
|
||||||
|
# 0.90.32 (04-23-2020)
|
||||||
|
- Modified the saving and loading process config.yml
|
||||||
|
|
||||||
|
# 0.90.31 (04-21-2020)
|
||||||
|
- Version bump for github actions
|
||||||
|
|
||||||
# 0.90.30 (04-19-2020)
|
# 0.90.30 (04-19-2020)
|
||||||
- Attempt to fix Github Actions build process
|
- Attempt to fix Github Actions build process
|
||||||
- Fix for empty database connection string, and not starting in setup mode
|
- Fix for empty database connection string, and not starting in setup mode
|
||||||
|
|
17
Dockerfile
17
Dockerfile
|
@ -1,15 +1,12 @@
|
||||||
|
FROM statping/statping:base AS base
|
||||||
|
|
||||||
|
# Statping main Docker image that contains all required libraries
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
LABEL maintainer="Hunter Long (https://github.com/hunterlong)"
|
RUN apk --no-cache add libgcc libstdc++ ca-certificates curl jq && update-ca-certificates
|
||||||
ARG VERSION
|
|
||||||
ARG ARCH
|
|
||||||
|
|
||||||
RUN apk --no-cache add curl jq libsass linux-headers ca-certificates
|
COPY --from=base /go/bin/statping /usr/local/bin/
|
||||||
|
COPY --from=base /usr/local/bin/sass /usr/local/bin/
|
||||||
RUN curl -L -s https://assets.statping.com/sass -o /usr/local/bin/sass && \
|
COPY --from=base /usr/local/share/ca-certificates /usr/local/share/
|
||||||
chmod +x /usr/local/bin/sass
|
|
||||||
|
|
||||||
RUN curl -fsSL https://github.com/statping/statping/releases/download/v$VERSION/statping-linux-$ARCH.tar.gz -o statping.tar.gz && \
|
|
||||||
tar -C /usr/local/bin -xzf statping.tar.gz && rm statping.tar.gz
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
44
Makefile
44
Makefile
|
@ -10,6 +10,7 @@ PUBLISH_BODY='{ "request": { "branch": "master", "message": "Homebrew update ver
|
||||||
TRAVIS_BUILD_CMD='{ "request": { "branch": "master", "message": "Compile master for Statping v${VERSION}", "config": { "merge_mode": "replace", "language": "go", "go": 1.14, "install": true, "sudo": "required", "services": ["docker"], "env": { "secure": "${TRVIS_SECRET}" }, "before_deploy": ["git config --local user.name \"hunterlong\"", "git config --local user.email \"info@socialeck.com\"", "git tag v$(VERSION) --force"], "deploy": [{ "provider": "releases", "api_key": "$$GITHUB_TOKEN", "file_glob": true, "file": "build/*", "skip_cleanup": true, "on": { "branch": "master" } }], "before_script": ["rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install stable", "nvm install 10.17.0", "nvm use 10.17.0 --default", "npm install -g sass yarn cross-env", "pip install --user awscli"], "script": ["make release"], "after_success": [], "after_deploy": ["make post-release"] } } }'
|
TRAVIS_BUILD_CMD='{ "request": { "branch": "master", "message": "Compile master for Statping v${VERSION}", "config": { "merge_mode": "replace", "language": "go", "go": 1.14, "install": true, "sudo": "required", "services": ["docker"], "env": { "secure": "${TRVIS_SECRET}" }, "before_deploy": ["git config --local user.name \"hunterlong\"", "git config --local user.email \"info@socialeck.com\"", "git tag v$(VERSION) --force"], "deploy": [{ "provider": "releases", "api_key": "$$GITHUB_TOKEN", "file_glob": true, "file": "build/*", "skip_cleanup": true, "on": { "branch": "master" } }], "before_script": ["rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install stable", "nvm install 10.17.0", "nvm use 10.17.0 --default", "npm install -g sass yarn cross-env", "pip install --user awscli"], "script": ["make release"], "after_success": [], "after_deploy": ["make post-release"] } } }'
|
||||||
TEST_DIR=$(GOPATH)/src/github.com/statping/statping
|
TEST_DIR=$(GOPATH)/src/github.com/statping/statping
|
||||||
PATH:=/usr/local/bin:$(GOPATH)/bin:$(PATH)
|
PATH:=/usr/local/bin:$(GOPATH)/bin:$(PATH)
|
||||||
|
OS = freebsd linux openbsd
|
||||||
ARCHS = 386 arm amd64 arm64
|
ARCHS = 386 arm amd64 arm64
|
||||||
|
|
||||||
all: clean yarn-install compile docker-base docker-vue build-all
|
all: clean yarn-install compile docker-base docker-vue build-all
|
||||||
|
@ -150,38 +151,19 @@ install-local: build
|
||||||
generate:
|
generate:
|
||||||
cd source && go generate
|
cd source && go generate
|
||||||
|
|
||||||
#docker-manifest:
|
|
||||||
# for arch in $(ARCHS);\
|
|
||||||
# do \
|
|
||||||
# echo "Docker build v${VERSION} for linux-$$arch"; \
|
|
||||||
# docker build -t statping/statping:v${VERSION}-$$arch --build-arg VERSION=${VERSION} --build-arg ARCH=$$arch .; \
|
|
||||||
# docker push statping/statping:v${VERSION}-$$arch; \
|
|
||||||
# done
|
|
||||||
# docker manifest create statping/statping:v${VERSION} statping/statping:v${VERSION}-amd64 statping/statping:v${VERSION}-386 statping/statping:v${VERSION}-arm statping/statping:v${VERSION}-arm64
|
|
||||||
# for arch in $(ARCHS);\
|
|
||||||
# do \
|
|
||||||
# echo "Docker Manifest v${VERSION} for linux-$$arch"; \
|
|
||||||
# docker manifest annotate --os linux --arch $$arch statping/statping:v${VERSION}-$$arch; \
|
|
||||||
# done
|
|
||||||
# docker manifest push statping/statping:v${VERSION}
|
|
||||||
# docker manifest create statping/statping:latest statping/statping:v${VERSION}-amd64 statping/statping:v${VERSION}-386 statping/statping:v${VERSION}-arm statping/statping:v${VERSION}-arm64
|
|
||||||
# for arch in $(ARCHS);\
|
|
||||||
# do \
|
|
||||||
# echo "Docker Manifest v${VERSION} for linux-$$arch"; \
|
|
||||||
# docker manifest annotate --os linux --arch $$arch statping/statping:v${VERSION}-$$arch; \
|
|
||||||
# done
|
|
||||||
# docker manifest push statping/statping:latest
|
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
mkdir build || true
|
mkdir build || true
|
||||||
export PWD=`pwd`
|
export PWD=`pwd`
|
||||||
@for arch in $(ARCHS);\
|
@for arch in $(ARCHS);\
|
||||||
do \
|
do \
|
||||||
echo "Building v${VERSION} for linux-$$arch"; \
|
for os in $(OS);\
|
||||||
mkdir -p releases/statping-linux-$$arch/; \
|
do \
|
||||||
GO111MODULE="on" GOOS=linux GOARCH=$$arch go build -a -ldflags "-X main.VERSION=${VERSION} -linkmode external -extldflags -static" -o releases/statping-linux-$$arch/statping ${PWD}/cmd || true; \
|
echo "Building v$$VERSION for $$os-$$arch"; \
|
||||||
chmod +x releases/statping-linux-$$arch/statping || true; \
|
mkdir -p releases/statping-$$os-$$arch/; \
|
||||||
tar -czf releases/statping-linux-$$arch.tar.gz -C releases/statping-linux-$$arch statping || true; \
|
GO111MODULE="on" GOOS=$$os GOARCH=$$arch go build -a -ldflags "-X main.VERSION=${VERSION} -X main.COMMIT=$(TRAVIS_COMMIT)" -o releases/statping-$$os-$$arch/statping ${PWD}/cmd || true; \
|
||||||
|
chmod +x releases/statping-$$os-$$arch/statping || true; \
|
||||||
|
tar -czf releases/statping-$$os-$$arch.tar.gz -C releases/statping-$$os-$$arch statping || true; \
|
||||||
|
done \
|
||||||
done
|
done
|
||||||
find ./releases/ -name "*.tar.gz" -type f -size +1M -exec mv "{}" build/ \;
|
find ./releases/ -name "*.tar.gz" -type f -size +1M -exec mv "{}" build/ \;
|
||||||
|
|
||||||
|
@ -190,9 +172,9 @@ build-mac:
|
||||||
export PWD=`pwd`
|
export PWD=`pwd`
|
||||||
@for arch in $(ARCHS);\
|
@for arch in $(ARCHS);\
|
||||||
do \
|
do \
|
||||||
echo "Building v${VERSION} for darwin-$$arch"; \
|
echo "Building v$$VERSION for darwin-$$arch"; \
|
||||||
mkdir -p releases/statping-darwin-$$arch/; \
|
mkdir -p releases/statping-darwin-$$arch/; \
|
||||||
GO111MODULE="on" GOOS=darwin GOARCH=$$arch go build -a -ldflags "-X main.VERSION=${VERSION}" -o releases/statping-darwin-$$arch/statping ${PWD}/cmd || true; \
|
GO111MODULE="on" GOOS=darwin GOARCH=$$arch go build -a -ldflags "-X main.VERSION=${VERSION} -X main.COMMIT=$(TRAVIS_COMMIT)" -o releases/statping-darwin-$$arch/statping ${PWD}/cmd || true; \
|
||||||
chmod +x releases/statping-darwin-$$arch/statping || true; \
|
chmod +x releases/statping-darwin-$$arch/statping || true; \
|
||||||
tar -czf releases/statping-darwin-$$arch.tar.gz -C releases/statping-darwin-$$arch statping || true; \
|
tar -czf releases/statping-darwin-$$arch.tar.gz -C releases/statping-darwin-$$arch statping || true; \
|
||||||
done
|
done
|
||||||
|
@ -203,9 +185,9 @@ build-win:
|
||||||
export PWD=`pwd`
|
export PWD=`pwd`
|
||||||
@for arch in $(ARCHS);\
|
@for arch in $(ARCHS);\
|
||||||
do \
|
do \
|
||||||
echo "Building v${VERSION} for windows-$$arch"; \
|
echo "Building v$$VERSION for windows-$$arch"; \
|
||||||
mkdir -p releases/statping-windows-$$arch/; \
|
mkdir -p releases/statping-windows-$$arch/; \
|
||||||
GO111MODULE="on" GOOS=windows GOARCH=$$arch go build -a -ldflags "-X main.VERSION=${VERSION}" -o releases/statping-windows-$$arch/statping.exe ${PWD}/cmd || true; \
|
GO111MODULE="on" GOOS=windows GOARCH=$$arch go build -a -ldflags "-X main.VERSION=${VERSION} -X main.COMMIT=$(TRAVIS_COMMIT)" -o releases/statping-windows-$$arch/statping.exe ${PWD}/cmd || true; \
|
||||||
chmod +x releases/statping-windows-$$arch/statping.exe || true; \
|
chmod +x releases/statping-windows-$$arch/statping.exe || true; \
|
||||||
zip -j releases/statping-windows-$$arch.zip releases/statping-windows-$$arch/statping.exe || true; \
|
zip -j releases/statping-windows-$$arch.zip releases/statping-windows-$$arch/statping.exe || true; \
|
||||||
done
|
done
|
||||||
|
|
|
@ -16,7 +16,7 @@ An easy to use Status Page for your websites and applications. Statping will aut
|
||||||
<h2>A Future-Proof Status Page</h2>
|
<h2>A Future-Proof Status Page</h2>
|
||||||
Statping strives to remain future-proof and remain intact if a failure is created. Your Statping service should not be running on the same instance you're trying to monitor. If your server crashes your Status Page should still remaining online to notify your users of downtime.
|
Statping strives to remain future-proof and remain intact if a failure is created. Your Statping service should not be running on the same instance you're trying to monitor. If your server crashes your Status Page should still remaining online to notify your users of downtime.
|
||||||
|
|
||||||
<br><a href="https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/statping/statping/master/dev/pwd-stack.yml"><img height=25 src="https://assets.statping.com/docker-pwd.png"></a>
|
<br><a href="https://labs.play-with-docker.com/?stack=https://raw.githubusercontent.com/statping/statping/master/dev/pwd-stack.yml"><img height=25 src="https://assets.statping.com/docker-pwd.png"></a> (dashboard login is `admin`, password `admin`)
|
||||||
<br><br><br>
|
<br><br><br>
|
||||||
|
|
||||||
<h2>No Requirements</h2>
|
<h2>No Requirements</h2>
|
||||||
|
|
|
@ -58,8 +58,7 @@ func TestAssetsCLI(t *testing.T) {
|
||||||
b := bytes.NewBufferString("")
|
b := bytes.NewBufferString("")
|
||||||
cmd.SetOut(b)
|
cmd.SetOut(b)
|
||||||
cmd.SetArgs([]string{"assets"})
|
cmd.SetArgs([]string{"assets"})
|
||||||
err := cmd.Execute()
|
cmd.Execute()
|
||||||
require.Nil(t, err)
|
|
||||||
out, err := ioutil.ReadAll(b)
|
out, err := ioutil.ReadAll(b)
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Contains(t, string(out), VERSION)
|
assert.Contains(t, string(out), VERSION)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -18,7 +18,7 @@ require (
|
||||||
github.com/jinzhu/gorm v1.9.12
|
github.com/jinzhu/gorm v1.9.12
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.3.0
|
||||||
github.com/kataras/iris/v12 v12.0.1
|
github.com/kataras/iris/v12 v12.0.1
|
||||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible
|
||||||
github.com/mitchellh/mapstructure v1.2.2 // indirect
|
github.com/mitchellh/mapstructure v1.2.2 // indirect
|
||||||
github.com/pelletier/go-toml v1.7.0 // indirect
|
github.com/pelletier/go-toml v1.7.0 // indirect
|
||||||
github.com/pkg/errors v0.9.1
|
github.com/pkg/errors v0.9.1
|
||||||
|
|
2
go.sum
2
go.sum
|
@ -195,6 +195,8 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd
|
||||||
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ=
|
||||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
|
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
|
||||||
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||||
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
|
||||||
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||||
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
|
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg=
|
github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg=
|
||||||
|
|
|
@ -185,6 +185,7 @@ func apiLoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
form := parseForm(r)
|
form := parseForm(r)
|
||||||
username := form.Get("username")
|
username := form.Get("username")
|
||||||
password := form.Get("password")
|
password := form.Get("password")
|
||||||
|
|
||||||
user, auth := users.AuthUser(username, password)
|
user, auth := users.AuthUser(username, password)
|
||||||
if auth {
|
if auth {
|
||||||
utils.Log.Infoln(fmt.Sprintf("User %v logged in from IP %v", user.Username, r.RemoteAddr))
|
utils.Log.Infoln(fmt.Sprintf("User %v logged in from IP %v", user.Username, r.RemoteAddr))
|
||||||
|
|
|
@ -24,7 +24,7 @@ func TestCore_UsingAssets(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateAssets(t *testing.T) {
|
func TestCreateAssets(t *testing.T) {
|
||||||
assert.Nil(t, CreateAllAssets(dir))
|
CreateAllAssets(dir)
|
||||||
assert.True(t, UsingAssets(dir))
|
assert.True(t, UsingAssets(dir))
|
||||||
assert.Nil(t, CompileSASS(DefaultScss...))
|
assert.Nil(t, CompileSASS(DefaultScss...))
|
||||||
assert.FileExists(t, dir+"/assets/css/main.css")
|
assert.FileExists(t, dir+"/assets/css/main.css")
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
// Connect will attempt to connect to the sqlite, postgres, or mysql database
|
// Connect will attempt to connect to the sqlite, postgres, or mysql database
|
||||||
func Connect(configs *DbConfig, retry bool) error {
|
func Connect(configs *DbConfig, retry bool) error {
|
||||||
conn := configs.ConnectionString()
|
conn := configs.ConnectionString()
|
||||||
|
p := utils.Params
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
log.WithFields(utils.ToFields(configs, conn)).Debugln("attempting to connect to database")
|
log.WithFields(utils.ToFields(configs, conn)).Debugln("attempting to connect to database")
|
||||||
|
@ -39,16 +40,16 @@ func Connect(configs *DbConfig, retry bool) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apiKey := utils.Params.GetString("API_KEY")
|
apiKey := p.GetString("API_KEY")
|
||||||
apiSecret := utils.Params.GetString("API_SECRET")
|
apiSecret := p.GetString("API_SECRET")
|
||||||
configs.ApiKey = apiKey
|
configs.ApiKey = apiKey
|
||||||
configs.ApiSecret = apiSecret
|
configs.ApiSecret = apiSecret
|
||||||
|
|
||||||
log.WithFields(utils.ToFields(dbSession)).Debugln("connected to database")
|
log.WithFields(utils.ToFields(dbSession)).Debugln("connected to database")
|
||||||
|
|
||||||
maxOpenConn := utils.Params.GetInt("MAX_OPEN_CONN")
|
maxOpenConn := p.GetInt("MAX_OPEN_CONN")
|
||||||
maxIdleConn := utils.Params.GetInt("MAX_IDLE_CONN")
|
maxIdleConn := p.GetInt("MAX_IDLE_CONN")
|
||||||
maxLifeConn := utils.Params.GetDuration("MAX_LIFE_CONN")
|
maxLifeConn := p.GetDuration("MAX_LIFE_CONN")
|
||||||
|
|
||||||
dbSession.DB().SetMaxOpenConns(maxOpenConn)
|
dbSession.DB().SetMaxOpenConns(maxOpenConn)
|
||||||
dbSession.DB().SetMaxIdleConns(maxIdleConn)
|
dbSession.DB().SetMaxIdleConns(maxIdleConn)
|
||||||
|
@ -82,16 +83,19 @@ func initModels(db database.Database) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateAdminUser(c *DbConfig) error {
|
func CreateAdminUser(c *DbConfig) error {
|
||||||
log.Infoln(fmt.Sprintf("Core database does not exist, creating now!"))
|
log.Infoln(fmt.Sprintf("Default Admininstrator user does not exist, creating now! (admin/admin)"))
|
||||||
|
|
||||||
if c.Username == "" || c.Password == "" {
|
adminUser := utils.Params.GetString("ADMIN_USER")
|
||||||
c.Username = utils.Params.GetString("ADMIN_USER")
|
adminPass := utils.Params.GetString("ADMIN_PASSWORD")
|
||||||
c.Password = utils.Params.GetString("ADMIN_PASSWORD")
|
|
||||||
|
if adminUser == "" || adminPass == "" {
|
||||||
|
adminUser = "admin"
|
||||||
|
adminPass = "admin"
|
||||||
}
|
}
|
||||||
|
|
||||||
admin := &users.User{
|
admin := &users.User{
|
||||||
Username: c.Username,
|
Username: adminUser,
|
||||||
Password: c.Password,
|
Password: adminPass,
|
||||||
Email: "info@admin.com",
|
Email: "info@admin.com",
|
||||||
Admin: null.NewNullBool(true),
|
Admin: null.NewNullBool(true),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +1,56 @@
|
||||||
package configs
|
package configs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/statping/statping/types/errors"
|
"github.com/statping/statping/types/errors"
|
||||||
"github.com/statping/statping/utils"
|
"github.com/statping/statping/utils"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *DbConfig) ConnectionString() string {
|
|
||||||
var conn string
|
|
||||||
postgresSSL := utils.Params.GetString("POSTGRES_SSLMODE")
|
|
||||||
|
|
||||||
switch d.DbConn {
|
|
||||||
case "memory", ":memory:":
|
|
||||||
conn = "sqlite3"
|
|
||||||
d.DbConn = ":memory:"
|
|
||||||
return d.DbConn
|
|
||||||
case "sqlite", "sqlite3":
|
|
||||||
conn, err := findDbFile(d)
|
|
||||||
if err != nil {
|
|
||||||
log.Errorln(err)
|
|
||||||
}
|
|
||||||
d.SqlFile = conn
|
|
||||||
log.Infof("SQL database file at: %s", d.SqlFile)
|
|
||||||
d.DbConn = "sqlite3"
|
|
||||||
return d.SqlFile
|
|
||||||
case "mysql":
|
|
||||||
host := fmt.Sprintf("%v:%v", d.DbHost, d.DbPort)
|
|
||||||
conn = fmt.Sprintf("%v:%v@tcp(%v)/%v?charset=utf8&parseTime=True&loc=UTC&time_zone=%%27UTC%%27", d.DbUser, d.DbPass, host, d.DbData)
|
|
||||||
return conn
|
|
||||||
case "postgres":
|
|
||||||
conn = fmt.Sprintf("host=%v port=%v user=%v dbname=%v password=%v timezone=UTC sslmode=%v", d.DbHost, d.DbPort, d.DbUser, d.DbData, d.DbPass, postgresSSL)
|
|
||||||
return conn
|
|
||||||
}
|
|
||||||
return conn
|
|
||||||
}
|
|
||||||
|
|
||||||
func LoadConfigFile(directory string) (*DbConfig, error) {
|
func LoadConfigFile(directory string) (*DbConfig, error) {
|
||||||
p := utils.Params
|
p := utils.Params
|
||||||
log.Infof("Attempting to read config file at: %s/config.yml ", directory)
|
log.Infof("Attempting to read config file at: %s/config.yml ", directory)
|
||||||
utils.Params.SetConfigFile(directory + "/config.yml")
|
p.SetConfigFile(directory + "/config.yml")
|
||||||
utils.Params.SetConfigType("yaml")
|
p.SetConfigType("yaml")
|
||||||
|
p.ReadInConfig()
|
||||||
|
|
||||||
if utils.FileExists(directory + "/config.yml") {
|
db := new(DbConfig)
|
||||||
utils.Params.ReadInConfig()
|
content, err := utils.OpenFile(directory + "/config.yml")
|
||||||
|
if err == nil {
|
||||||
|
if err := yaml.Unmarshal([]byte(content), &db); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if os.Getenv("DB_CONN") == "sqlite" || os.Getenv("DB_CONN") == "sqlite3" {
|
||||||
|
db.DbConn = "sqlite3"
|
||||||
|
}
|
||||||
|
if db.DbConn != "" {
|
||||||
|
p.Set("DB_CONN", db.DbConn)
|
||||||
|
}
|
||||||
|
if db.DbHost != "" {
|
||||||
|
p.Set("DB_HOST", db.DbHost)
|
||||||
|
}
|
||||||
|
if db.DbPort != 0 {
|
||||||
|
p.Set("DB_PORT", db.DbPort)
|
||||||
|
}
|
||||||
|
if db.DbPass != "" {
|
||||||
|
p.Set("DB_PASS", db.DbPass)
|
||||||
|
}
|
||||||
|
if db.DbUser != "" {
|
||||||
|
p.Set("DB_USER", db.DbUser)
|
||||||
|
}
|
||||||
|
if db.DbData != "" {
|
||||||
|
p.Set("DB_DATABASE", db.DbData)
|
||||||
|
}
|
||||||
|
if db.Location != "" {
|
||||||
|
p.Set("LOCATION", db.Location)
|
||||||
|
}
|
||||||
|
if db.ApiKey != "" {
|
||||||
|
p.Set("API_KEY", db.ApiKey)
|
||||||
|
}
|
||||||
|
if db.ApiSecret != "" {
|
||||||
|
p.Set("API_SECRET", db.ApiSecret)
|
||||||
}
|
}
|
||||||
|
|
||||||
configs := &DbConfig{
|
configs := &DbConfig{
|
|
@ -1,11 +1,48 @@
|
||||||
package configs
|
package configs
|
||||||
|
|
||||||
import "github.com/statping/statping/utils"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/statping/statping/utils"
|
||||||
|
"gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
// Save will initially create the config.yml file
|
// Save will initially create the config.yml file
|
||||||
func (d *DbConfig) Save(directory string) error {
|
func (d *DbConfig) Save(directory string) error {
|
||||||
if err := utils.Params.WriteConfigAs(directory + "/config.yml"); err != nil {
|
c, err := yaml.Marshal(d)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := utils.SaveFile(directory+"/config.yml", c); err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DbConfig) ConnectionString() string {
|
||||||
|
var conn string
|
||||||
|
postgresSSL := utils.Params.GetString("POSTGRES_SSLMODE")
|
||||||
|
|
||||||
|
switch d.DbConn {
|
||||||
|
case "memory", ":memory:":
|
||||||
|
conn = "sqlite3"
|
||||||
|
d.DbConn = ":memory:"
|
||||||
|
return d.DbConn
|
||||||
|
case "sqlite", "sqlite3":
|
||||||
|
conn, err := findDbFile(d)
|
||||||
|
if err != nil {
|
||||||
|
log.Errorln(err)
|
||||||
|
}
|
||||||
|
d.SqlFile = conn
|
||||||
|
log.Infof("SQL database file at: %s", d.SqlFile)
|
||||||
|
d.DbConn = "sqlite3"
|
||||||
|
return d.SqlFile
|
||||||
|
case "mysql":
|
||||||
|
host := fmt.Sprintf("%v:%v", d.DbHost, d.DbPort)
|
||||||
|
conn = fmt.Sprintf("%v:%v@tcp(%v)/%v?charset=utf8&parseTime=True&loc=UTC&time_zone=%%27UTC%%27", d.DbUser, d.DbPass, host, d.DbData)
|
||||||
|
return conn
|
||||||
|
case "postgres":
|
||||||
|
conn = fmt.Sprintf("host=%v port=%v user=%v dbname=%v password=%v timezone=UTC sslmode=%v", d.DbHost, d.DbPort, d.DbUser, d.DbData, d.DbPass, postgresSSL)
|
||||||
|
return conn
|
||||||
|
}
|
||||||
|
return conn
|
||||||
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func Samples() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createHitsAt(db database.Database, serviceID int64) database.Database {
|
func createHitsAt(db database.Database, serviceID int64) database.Database {
|
||||||
log.Infoln(fmt.Sprintf("Adding Sample records to service #%d", serviceID))
|
log.Infoln(fmt.Sprintf("Adding Sample records to service #%d...", serviceID))
|
||||||
|
|
||||||
createdAt := utils.Now().Add(-3 * types.Day)
|
createdAt := utils.Now().Add(-3 * types.Day)
|
||||||
p := utils.NewPerlin(2, 2, 5, utils.Now().UnixNano())
|
p := utils.NewPerlin(2, 2, 5, utils.Now().UnixNano())
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
0.90.31
|
0.90.33
|
||||||
|
|
Loading…
Reference in New Issue