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 {
|
||||
return 0, err
|
||||
}
|
||||
fmt.Println(uuid)
|
||||
fmt.Println("new checkin: ",uuid)
|
||||
return uuid.(int64), err
|
||||
}
|
||||
|
||||
|
|
10
emailer.go
10
emailer.go
|
@ -30,7 +30,9 @@ func AddEmail(email *types.Email) {
|
|||
}
|
||||
|
||||
func EmailerQueue() {
|
||||
defer EmailerQueue()
|
||||
if emailQue == nil {
|
||||
return
|
||||
}
|
||||
uniques := []*types.Email{}
|
||||
for _, out := range emailQue.Outgoing {
|
||||
if isUnique(uniques, out) {
|
||||
|
@ -42,6 +44,7 @@ func EmailerQueue() {
|
|||
emailQue.Outgoing = nil
|
||||
fmt.Println("running emailer queue")
|
||||
time.Sleep(60 * time.Second)
|
||||
EmailerQueue()
|
||||
}
|
||||
|
||||
func isUnique(arr []*types.Email, obj *types.Email) bool {
|
||||
|
@ -78,7 +81,10 @@ func SendFailureEmail(service *Service) {
|
|||
}
|
||||
|
||||
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.Mailer = gomail.NewDialer(config.Host, config.Port, config.Username, config.Password)
|
||||
emailQue.Mailer.TLSConfig = &tls.Config{InsecureSkipVerify: true}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
<div class="col-12">
|
||||
|
||||
{{ if not . }}
|
||||
{{ if .Error }}
|
||||
<div class="alert alert-danger" role="alert">
|
||||
Incorrect login information submitted, try again.
|
||||
</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/html:/usr/share/nginx/html:ro
|
||||
- /home/ubuntu/nginx/dhparam:/etc/nginx/dhparam
|
||||
environment:
|
||||
DEFAULT_HOST: localhost
|
||||
|
||||
statup:
|
||||
container_name: statup
|
||||
image: hunterlong/statup
|
||||
build: https://github.com/hunterlong/statup.git
|
||||
networks:
|
||||
- internet
|
||||
- database
|
||||
depends_on:
|
||||
- nginx
|
||||
- postgres
|
||||
volumes:
|
||||
- /home/ubuntu/statup:/app
|
||||
environment:
|
||||
VIRTUAL_HOST: statup.cjx.io
|
||||
VIRTUAL_HOST: localhost
|
||||
VIRTUAL_PORT: 8080
|
||||
DOMAIN: statup.cjx.io
|
||||
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:"-"`
|
||||
Username string `yaml:"-"`
|
||||
Password string `yaml:"-"`
|
||||
Email string `yaml:"-"`
|
||||
Error error `yaml:"-"`
|
||||
}
|
||||
|
||||
|
@ -59,6 +60,7 @@ func ProcessSetupHandler(w http.ResponseWriter, r *http.Request) {
|
|||
domain,
|
||||
username,
|
||||
password,
|
||||
email,
|
||||
nil,
|
||||
}
|
||||
err := config.Save()
|
||||
|
|
30
web.go
30
web.go
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/hunterlong/statup/types"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
@ -102,7 +103,8 @@ func LoginHandler(w http.ResponseWriter, r *http.Request) {
|
|||
session.Save(r, w)
|
||||
http.Redirect(w, r, "/dashboard", http.StatusSeeOther)
|
||||
} 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)
|
||||
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 {
|
||||
|
@ -185,13 +207,13 @@ type dashboard struct {
|
|||
func DashboardHandler(w http.ResponseWriter, r *http.Request) {
|
||||
session, _ := store.Get(r, cookieKey)
|
||||
if auth, ok := session.Values["authenticated"].(bool); !ok || !auth {
|
||||
ExecuteResponse(w, r, "login.html", nil)
|
||||
err := ErrorResponse{}
|
||||
ExecuteResponse(w, r, "login.html", err)
|
||||
} else {
|
||||
fails, _ := CountFailures()
|
||||
out := dashboard{services, core, CountOnline(), len(services), fails}
|
||||
ExecuteResponse(w, r, "dashboard.html", out)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
type serviceHandler struct {
|
||||
|
|
Loading…
Reference in New Issue