diff --git a/checkin.go b/checkin.go
index ed32ea43..30d29853 100644
--- a/checkin.go
+++ b/checkin.go
@@ -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
}
diff --git a/emailer.go b/emailer.go
index bb3ce3fa..3aa56e8d 100644
--- a/emailer.go
+++ b/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}
diff --git a/html/tmpl/login.html b/html/tmpl/login.html
index 6b2e80d3..1f57ccdf 100644
--- a/html/tmpl/login.html
+++ b/html/tmpl/login.html
@@ -16,7 +16,7 @@
- {{ if not . }}
+ {{ if .Error }}
Incorrect login information submitted, try again.
diff --git a/servers/README.md b/servers/README.md
new file mode 100644
index 00000000..42b830e3
--- /dev/null
+++ b/servers/README.md
@@ -0,0 +1,11 @@
+# Statup Servers
+
+
+## Docker
+
+
+## Docker Compose
+
+
+## AWS EC2
+
diff --git a/docker-compose.yml b/servers/docker-compose.yml
similarity index 89%
rename from docker-compose.yml
rename to servers/docker-compose.yml
index 170a8570..aa2dfc20 100644
--- a/docker-compose.yml
+++ b/servers/docker-compose.yml
@@ -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
diff --git a/servers/ubuntu.sh b/servers/ubuntu.sh
new file mode 100644
index 00000000..37a5025c
--- /dev/null
+++ b/servers/ubuntu.sh
@@ -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
\ No newline at end of file
diff --git a/setup.go b/setup.go
index 0b7e5752..ac8c4c16 100644
--- a/setup.go
+++ b/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()
diff --git a/web.go b/web.go
index 13e2c0a6..75a9806d 100644
--- a/web.go
+++ b/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 {