mirror of https://github.com/statping/statping
errs
parent
e4eb5370f0
commit
e7771844b1
|
@ -51,7 +51,6 @@ notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then travis_wait 30 docker pull karalabe/xgo-latest; fi
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
|
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
|
||||||
|
@ -71,6 +70,7 @@ script:
|
||||||
- go test -v -covermode=count -coverprofile=coverage.out && $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $COVERALLS
|
- go test -v -covermode=count -coverprofile=coverage.out && $GOPATH/bin/goveralls -coverprofile=coverage.out -service=travis -repotoken $COVERALLS
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
|
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then travis_wait 30 docker pull karalabe/xgo-latest; fi
|
||||||
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then /bin/bash -c .travis/build.sh; fi
|
- if [[ "$TRAVIS_BRANCH" == "master" ]]; then /bin/bash -c .travis/build.sh; fi
|
||||||
|
|
||||||
after_deploy:
|
after_deploy:
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"upper.io/db.v3/mysql"
|
"upper.io/db.v3/mysql"
|
||||||
"upper.io/db.v3/postgresql"
|
"upper.io/db.v3/postgresql"
|
||||||
"upper.io/db.v3/sqlite"
|
"upper.io/db.v3/sqlite"
|
||||||
|
"github.com/hunterlong/statup/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -26,6 +27,7 @@ func DbConnection(dbType string) error {
|
||||||
}
|
}
|
||||||
dbSession, err = sqlite.Open(sqliteSettings)
|
dbSession, err = sqlite.Open(sqliteSettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Send(3, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if dbType == "mysql" {
|
} else if dbType == "mysql" {
|
||||||
|
@ -40,6 +42,7 @@ func DbConnection(dbType string) error {
|
||||||
}
|
}
|
||||||
dbSession, err = mysql.Open(mysqlSettings)
|
dbSession, err = mysql.Open(mysqlSettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Send(3, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -55,6 +58,7 @@ func DbConnection(dbType string) error {
|
||||||
}
|
}
|
||||||
dbSession, err = postgresql.Open(postgresSettings)
|
dbSession, err = postgresql.Open(postgresSettings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Send(3, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +80,7 @@ func DeleteAllSince(table string, date time.Time) {
|
||||||
sql := fmt.Sprintf("DELETE FROM %v WHERE created_at < '%v';", table, date.Format("2006-01-02"))
|
sql := fmt.Sprintf("DELETE FROM %v WHERE created_at < '%v';", table, date.Format("2006-01-02"))
|
||||||
_, err := dbSession.Exec(db.Raw(sql))
|
_, err := dbSession.Exec(db.Raw(sql))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
log.Send(2, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,9 @@ func EmailerQueue() {
|
||||||
uniques := []*types.Email{}
|
uniques := []*types.Email{}
|
||||||
for _, out := range emailQue.Outgoing {
|
for _, out := range emailQue.Outgoing {
|
||||||
if isUnique(uniques, out) {
|
if isUnique(uniques, out) {
|
||||||
fmt.Printf("sending email to: %v \n", out.To)
|
msg := fmt.Sprintf("sending email to: %v \n", out.To)
|
||||||
Send(out)
|
Send(out)
|
||||||
|
log.Send(0, msg)
|
||||||
uniques = append(uniques, out)
|
uniques = append(uniques, out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +66,6 @@ func Send(em *types.Email) {
|
||||||
m.SetBody("text/html", source)
|
m.SetBody("text/html", source)
|
||||||
if err := emailQue.Mailer.DialAndSend(m); err != nil {
|
if err := emailQue.Mailer.DialAndSend(m); err != nil {
|
||||||
log.Send(2, err)
|
log.Send(2, err)
|
||||||
fmt.Println(err)
|
|
||||||
}
|
}
|
||||||
emailQue.LastSent++
|
emailQue.LastSent++
|
||||||
emailQue.LastSentTime = time.Now()
|
emailQue.LastSentTime = time.Now()
|
||||||
|
@ -95,12 +95,12 @@ func LoadMailer(config *types.Communication) *gomail.Dialer {
|
||||||
func EmailTemplate(tmpl string, data interface{}) string {
|
func EmailTemplate(tmpl string, data interface{}) string {
|
||||||
emailTpl, err := emailBox.String(tmpl)
|
emailTpl, err := emailBox.String(tmpl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Send(3, err)
|
||||||
}
|
}
|
||||||
t := template.New("email")
|
t := template.New("email")
|
||||||
t, err = t.Parse(emailTpl)
|
t, err = t.Parse(emailTpl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Send(3, err)
|
||||||
}
|
}
|
||||||
var tpl bytes.Buffer
|
var tpl bytes.Buffer
|
||||||
if err := t.Execute(&tpl, data); err != nil {
|
if err := t.Execute(&tpl, data); err != nil {
|
||||||
|
|
|
@ -34,6 +34,7 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Panic(err interface{}) {
|
func Panic(err interface{}) {
|
||||||
|
lg.Printf("PANIC: %v\n", err)
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue