mirror of https://github.com/statping/statping
docker build, static golang builds
parent
29659a4413
commit
969beb2cb5
|
@ -51,6 +51,29 @@ jobs:
|
|||
test:
|
||||
needs: compile
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
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
|
||||
|
||||
mariadb:
|
||||
image: mariadb:latest
|
||||
ports:
|
||||
- 3306:3306
|
||||
env:
|
||||
MYSQL_USER: root
|
||||
MYSQL_PASSWORD: password123
|
||||
MYSQL_DATABASE: statping
|
||||
MYSQL_ROOT_PASSWORD: password123
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
|
@ -343,12 +366,30 @@ jobs:
|
|||
|
||||
- name: Latest/Version Docker Image
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
env:
|
||||
VERSION: ${{ env.VERSION }}
|
||||
ARCH: amd64
|
||||
DOCKER_CLI_EXPERIMENTAL: enabled
|
||||
with:
|
||||
name: statping/statping
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
dockerfile: Dockerfile
|
||||
tags: "latest,v${{ env.VERSION }}"
|
||||
buildargs: VERSION,ARCH
|
||||
|
||||
- name: ARM Docker Image
|
||||
uses: elgohr/Publish-Docker-Github-Action@master
|
||||
env:
|
||||
VERSION: ${{ env.VERSION }}
|
||||
ARCH: arm
|
||||
with:
|
||||
name: statping/statping
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||
dockerfile: Dockerfile
|
||||
tags: "arm"
|
||||
buildargs: VERSION,ARCH
|
||||
|
||||
sentry-release:
|
||||
needs: [test, build-linux, build-mac, build-windows]
|
||||
|
|
6
Makefile
6
Makefile
|
@ -158,7 +158,7 @@ build-linux:
|
|||
do \
|
||||
for os in $(OS);\
|
||||
do \
|
||||
echo "Building v$$VERSION for $$os-$$arch"; \
|
||||
echo "Building v${VERSION} for $$os-$$arch"; \
|
||||
mkdir -p releases/statping-$$os-$$arch/; \
|
||||
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; \
|
||||
|
@ -172,7 +172,7 @@ build-mac:
|
|||
export PWD=`pwd`
|
||||
@for arch in $(ARCHS);\
|
||||
do \
|
||||
echo "Building v$$VERSION for darwin-$$arch"; \
|
||||
echo "Building v${VERSION} for darwin-$$arch"; \
|
||||
mkdir -p releases/statping-darwin-$$arch/; \
|
||||
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; \
|
||||
|
@ -185,7 +185,7 @@ build-win:
|
|||
export PWD=`pwd`
|
||||
@for arch in $(ARCHS);\
|
||||
do \
|
||||
echo "Building v$$VERSION for windows-$$arch"; \
|
||||
echo "Building v${VERSION} for windows-$$arch"; \
|
||||
mkdir -p releases/statping-windows-$$arch/; \
|
||||
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; \
|
||||
|
|
55
cmd/cli.go
55
cmd/cli.go
|
@ -283,61 +283,6 @@ func runOnce() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// HelpEcho prints out available commands and flags for Statping
|
||||
func HelpEcho() {
|
||||
fmt.Printf("Statping v%v - Statping.com\n", VERSION)
|
||||
fmt.Printf("A simple Application Status Monitor that is opensource and lightweight.\n")
|
||||
fmt.Printf("Commands:\n")
|
||||
fmt.Println(" statping - Main command to run Statping server")
|
||||
fmt.Println(" statping version - Returns the current version of Statping")
|
||||
fmt.Println(" statping run - Check all services 1 time and then quit")
|
||||
fmt.Println(" statping assets - Dump all assets used locally to be edited.")
|
||||
//fmt.Println(" statping static - Creates a static HTML file of the index page")
|
||||
fmt.Println(" statping sass - Compile .scss files into the css directory")
|
||||
fmt.Println(" statping env - Show all environment variables being used for Statping")
|
||||
fmt.Println(" statping update - Attempts to update to the latest version")
|
||||
fmt.Println(" statping export - Exports your Statping settings to a 'statping-export.json' file.")
|
||||
fmt.Println(" statping import <file> - Imports settings from a previously saved JSON file.")
|
||||
fmt.Println(" statping help - Shows the user basic information about Statping")
|
||||
fmt.Printf("Flags:\n")
|
||||
fmt.Println(" -ip 127.0.0.1 - Run HTTP server on specific IP address (default: localhost)")
|
||||
fmt.Println(" -port 8080 - Run HTTP server on Port (default: 8080)")
|
||||
fmt.Println(" -verbose 1 - Verbose mode levels 1 - 4 (default: 1)")
|
||||
fmt.Println(" -env path/debug.env - Optional .env file to set as environment variables while running server")
|
||||
fmt.Printf("Environment Variables:\n")
|
||||
fmt.Println(" PORT - Set the outgoing port for the HTTP server (or use -port)")
|
||||
fmt.Println(" IP - Bind a specific IP address to the HTTP server (or use -ip)")
|
||||
fmt.Println(" VERBOSE - Display more logs in verbose mode. (1 - 4)")
|
||||
fmt.Println(" STATPING_DIR - Set a absolute path for the root path of Statping server (logs, assets, SQL db)")
|
||||
fmt.Println(" DB_CONN - Automatic Database connection (sqlite, postgres, mysql)")
|
||||
fmt.Println(" DB_HOST - Database hostname or IP address")
|
||||
fmt.Println(" DB_USER - Database username")
|
||||
fmt.Println(" DB_PASS - Database password")
|
||||
fmt.Println(" DB_PORT - Database port (5432, 3306, ...)")
|
||||
fmt.Println(" DB_DATABASE - Database connection's database name")
|
||||
fmt.Println(" POSTGRES_SSLMODE - Enable Postgres SSL Mode 'ssl_mode=VALUE' (enable/disable/verify-full/verify-ca)")
|
||||
fmt.Println(" DISABLE_LOGS - Disable viewing and writing to the log file (default is false)")
|
||||
fmt.Println(" GO_ENV - Run Statping in testmode, will bypass HTTP authentication (if set as 'test')")
|
||||
fmt.Println(" NAME - Set a name for the Statping status page")
|
||||
fmt.Println(" DESCRIPTION - Set a description for the Statping status page")
|
||||
fmt.Println(" DOMAIN - Set a URL for the Statping status page")
|
||||
fmt.Println(" ADMIN_USER - Username for administrator account (default: admin)")
|
||||
fmt.Println(" ADMIN_PASS - Password for administrator account (default: admin)")
|
||||
fmt.Println(" USE_ASSETS - Automatically use assets from 'assets folder' (true/false)")
|
||||
fmt.Println(" HTTP_PROXY - Use a HTTP Proxy for HTTP Requests")
|
||||
fmt.Println(" AUTH_USERNAME - HTTP Basic Authentication username")
|
||||
fmt.Println(" AUTH_PASSWORD - HTTP Basic Authentication password")
|
||||
fmt.Println(" BASE_PATH - Set the base URL prefix (set to 'monitor' if URL is domain.com/monitor)")
|
||||
fmt.Println(" PREFIX - A Prefix for each value in Prometheus /metric exporter")
|
||||
fmt.Println(" API_KEY - Set a custom API Key for Statping")
|
||||
fmt.Println(" API_SECRET - Set a custom API Secret for API Authentication")
|
||||
fmt.Println(" MAX_OPEN_CONN - Set Maximum Open Connections for database server (default: 5)")
|
||||
fmt.Println(" MAX_IDLE_CONN - Set Maximum Idle Connections for database server")
|
||||
fmt.Println(" MAX_LIFE_CONN - Set Maximum Life Connections for database server")
|
||||
fmt.Println(" * You can insert environment variables into a '.env' file in root directory.")
|
||||
fmt.Println("Give Statping a Star at https://github.com/statping/statping")
|
||||
}
|
||||
|
||||
func checkGithubUpdates() (githubResponse, error) {
|
||||
url := "https://api.github.com/repos/statping/statping/releases/latest"
|
||||
contents, _, err := utils.HttpRequest(url, "GET", nil, nil, nil, time.Duration(2*time.Second), true)
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package configs
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSQLiteConfig(t *testing.T) {
|
||||
sqlite := &DbConfig{
|
||||
DbConn: "sqlite",
|
||||
DbHost: "localhost",
|
||||
DbUser: "",
|
||||
DbPass: "",
|
||||
DbData: "",
|
||||
DbPort: 0,
|
||||
}
|
||||
|
||||
err := Connect(sqlite, false)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestMySQLConfig(t *testing.T) {
|
||||
mysql := &DbConfig{
|
||||
DbConn: "mysql",
|
||||
DbHost: "localhost",
|
||||
DbUser: "root",
|
||||
DbPass: "password123",
|
||||
DbData: "statping",
|
||||
DbPort: 3306,
|
||||
}
|
||||
|
||||
err := Connect(mysql, false)
|
||||
require.Nil(t, err)
|
||||
}
|
||||
|
||||
func TestPostgresConfig(t *testing.T) {
|
||||
postgres := &DbConfig{
|
||||
DbConn: "postgres",
|
||||
DbHost: "localhost",
|
||||
DbUser: "root",
|
||||
DbPass: "password123",
|
||||
DbData: "statping",
|
||||
DbPort: 5432,
|
||||
}
|
||||
|
||||
err := Connect(postgres, false)
|
||||
require.Nil(t, err)
|
||||
}
|
|
@ -39,6 +39,11 @@ func LoadConfigFile(directory string) (*DbConfig, error) {
|
|||
p := utils.Params
|
||||
log.Infof("Attempting to read config file at: %s/config.yml ", directory)
|
||||
utils.Params.SetConfigFile(directory + "/config.yml")
|
||||
utils.Params.SetConfigType("yaml")
|
||||
|
||||
if utils.FileExists(directory + "/config.yml") {
|
||||
utils.Params.ReadInConfig()
|
||||
}
|
||||
|
||||
configs := &DbConfig{
|
||||
DbConn: p.GetString("DB_CONN"),
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.90.30
|
||||
0.90.31
|
||||
|
|
Loading…
Reference in New Issue