mirror of https://github.com/statping/statping
upgrades
parent
0660debfc6
commit
22cc4ca841
|
@ -30,7 +30,7 @@ func (u *Checkin) Create() (int64, error) {
|
||||||
if uuid == nil {
|
if uuid == nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
fmt.Println(uuid)
|
fmt.Println("new checkin: ",uuid)
|
||||||
return uuid.(int64), err
|
return uuid.(int64), err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
10
emailer.go
10
emailer.go
|
@ -30,7 +30,9 @@ func AddEmail(email *types.Email) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func EmailerQueue() {
|
func EmailerQueue() {
|
||||||
defer EmailerQueue()
|
if emailQue == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
uniques := []*types.Email{}
|
uniques := []*types.Email{}
|
||||||
for _, out := range emailQue.Outgoing {
|
for _, out := range emailQue.Outgoing {
|
||||||
if isUnique(uniques, out) {
|
if isUnique(uniques, out) {
|
||||||
|
@ -42,6 +44,7 @@ func EmailerQueue() {
|
||||||
emailQue.Outgoing = nil
|
emailQue.Outgoing = nil
|
||||||
fmt.Println("running emailer queue")
|
fmt.Println("running emailer queue")
|
||||||
time.Sleep(60 * time.Second)
|
time.Sleep(60 * time.Second)
|
||||||
|
EmailerQueue()
|
||||||
}
|
}
|
||||||
|
|
||||||
func isUnique(arr []*types.Email, obj *types.Email) bool {
|
func isUnique(arr []*types.Email, obj *types.Email) bool {
|
||||||
|
@ -78,7 +81,10 @@ func SendFailureEmail(service *Service) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadMailer(config *types.Communication) *gomail.Dialer {
|
func LoadMailer(config *types.Communication) *gomail.Dialer {
|
||||||
emailQue = &Que{}
|
if config.Host == "" || config.Username == "" || config.Password == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
emailQue = new(Que)
|
||||||
emailQue.Outgoing = []*types.Email{}
|
emailQue.Outgoing = []*types.Email{}
|
||||||
emailQue.Mailer = gomail.NewDialer(config.Host, config.Port, config.Username, config.Password)
|
emailQue.Mailer = gomail.NewDialer(config.Host, config.Port, config.Username, config.Password)
|
||||||
emailQue.Mailer.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
emailQue.Mailer.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
|
|
||||||
{{ if not . }}
|
{{ if .Error }}
|
||||||
<div class="alert alert-danger" role="alert">
|
<div class="alert alert-danger" role="alert">
|
||||||
Incorrect login information submitted, try again.
|
Incorrect login information submitted, try again.
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Statup Servers
|
||||||
|
|
||||||
|
|
||||||
|
## Docker
|
||||||
|
|
||||||
|
|
||||||
|
## Docker Compose
|
||||||
|
|
||||||
|
|
||||||
|
## AWS EC2
|
||||||
|
|
|
@ -17,20 +17,21 @@ services:
|
||||||
- /home/ubuntu/nginx/vhost:/etc/nginx/vhost.d
|
- /home/ubuntu/nginx/vhost:/etc/nginx/vhost.d
|
||||||
- /home/ubuntu/nginx/html:/usr/share/nginx/html:ro
|
- /home/ubuntu/nginx/html:/usr/share/nginx/html:ro
|
||||||
- /home/ubuntu/nginx/dhparam:/etc/nginx/dhparam
|
- /home/ubuntu/nginx/dhparam:/etc/nginx/dhparam
|
||||||
|
environment:
|
||||||
|
DEFAULT_HOST: localhost
|
||||||
|
|
||||||
statup:
|
statup:
|
||||||
container_name: statup
|
container_name: statup
|
||||||
image: hunterlong/statup
|
build: https://github.com/hunterlong/statup.git
|
||||||
networks:
|
networks:
|
||||||
- internet
|
- internet
|
||||||
- database
|
- database
|
||||||
depends_on:
|
depends_on:
|
||||||
- nginx
|
|
||||||
- postgres
|
- postgres
|
||||||
volumes:
|
volumes:
|
||||||
- /home/ubuntu/statup:/app
|
- /home/ubuntu/statup:/app
|
||||||
environment:
|
environment:
|
||||||
VIRTUAL_HOST: statup.cjx.io
|
VIRTUAL_HOST: localhost
|
||||||
VIRTUAL_PORT: 8080
|
VIRTUAL_PORT: 8080
|
||||||
DOMAIN: statup.cjx.io
|
DOMAIN: statup.cjx.io
|
||||||
DB_HOST: postgres
|
DB_HOST: postgres
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
VERSION=v0.18
|
||||||
|
|
||||||
|
wget https://github.com/hunterlong/statup/releases/download/$VERSION/statup-linux-x64
|
||||||
|
mv statup-linux-x64 /usr/local/bin/statup
|
||||||
|
chmod +x /usr/local/bin/statup
|
2
setup.go
2
setup.go
|
@ -24,6 +24,7 @@ type DbConfig struct {
|
||||||
Domain string `yaml:"-"`
|
Domain string `yaml:"-"`
|
||||||
Username string `yaml:"-"`
|
Username string `yaml:"-"`
|
||||||
Password string `yaml:"-"`
|
Password string `yaml:"-"`
|
||||||
|
Email string `yaml:"-"`
|
||||||
Error error `yaml:"-"`
|
Error error `yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +60,7 @@ func ProcessSetupHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
domain,
|
domain,
|
||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
|
email,
|
||||||
nil,
|
nil,
|
||||||
}
|
}
|
||||||
err := config.Save()
|
err := config.Save()
|
||||||
|
|
30
web.go
30
web.go
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/hunterlong/statup/types"
|
"github.com/hunterlong/statup/types"
|
||||||
"html/template"
|
"html/template"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -102,7 +103,8 @@ func LoginHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
session.Save(r, w)
|
session.Save(r, w)
|
||||||
http.Redirect(w, r, "/dashboard", http.StatusSeeOther)
|
http.Redirect(w, r, "/dashboard", http.StatusSeeOther)
|
||||||
} else {
|
} else {
|
||||||
ExecuteResponse(w, r, "login.html", auth)
|
err := ErrorResponse{Error: "Incorrect login information submitted, try again."}
|
||||||
|
ExecuteResponse(w, r, "login.html", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +159,27 @@ func SetupHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ExecuteResponse(w, r, "setup.html", nil)
|
port := 5432
|
||||||
|
if os.Getenv("DB_CONN") == "mysql" {
|
||||||
|
port = 3306
|
||||||
|
}
|
||||||
|
var data interface{}
|
||||||
|
if os.Getenv("DB_CONN") != "" {
|
||||||
|
data = &DbConfig{
|
||||||
|
DbConn: os.Getenv("DB_CONN"),
|
||||||
|
DbHost: os.Getenv("DB_HOST"),
|
||||||
|
DbUser: os.Getenv("DB_USER"),
|
||||||
|
DbPass: os.Getenv("DB_PASS"),
|
||||||
|
DbData: os.Getenv("DB_DATABASE"),
|
||||||
|
DbPort: port,
|
||||||
|
Project: os.Getenv("NAME"),
|
||||||
|
Description: os.Getenv("DESCRIPTION"),
|
||||||
|
Email: "",
|
||||||
|
Username: "admin",
|
||||||
|
Password: "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ExecuteResponse(w, r, "setup.html", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
type index struct {
|
type index struct {
|
||||||
|
@ -185,13 +207,13 @@ type dashboard struct {
|
||||||
func DashboardHandler(w http.ResponseWriter, r *http.Request) {
|
func DashboardHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
session, _ := store.Get(r, cookieKey)
|
session, _ := store.Get(r, cookieKey)
|
||||||
if auth, ok := session.Values["authenticated"].(bool); !ok || !auth {
|
if auth, ok := session.Values["authenticated"].(bool); !ok || !auth {
|
||||||
ExecuteResponse(w, r, "login.html", nil)
|
err := ErrorResponse{}
|
||||||
|
ExecuteResponse(w, r, "login.html", err)
|
||||||
} else {
|
} else {
|
||||||
fails, _ := CountFailures()
|
fails, _ := CountFailures()
|
||||||
out := dashboard{services, core, CountOnline(), len(services), fails}
|
out := dashboard{services, core, CountOnline(), len(services), fails}
|
||||||
ExecuteResponse(w, r, "dashboard.html", out)
|
ExecuteResponse(w, r, "dashboard.html", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type serviceHandler struct {
|
type serviceHandler struct {
|
||||||
|
|
Loading…
Reference in New Issue