fix: update to compile
yolo it
This commit is contained in:
parent
4811755f88
commit
b73a51e396
4 changed files with 11 additions and 13 deletions
|
@ -6,11 +6,6 @@ import (
|
|||
. "git.exozy.me/exozyme/status/scanner"
|
||||
)
|
||||
|
||||
// change implementation here
|
||||
func OpenDatabase(dir string) (Database, error) {
|
||||
return OpenPrototypeDb(dir)
|
||||
}
|
||||
|
||||
type Database interface {
|
||||
// dump data to disk
|
||||
Persist() error
|
||||
|
|
|
@ -23,7 +23,7 @@ type PrototypeDb struct {
|
|||
}
|
||||
|
||||
// Load the newest backup, or start anew
|
||||
func OpenPrototypeDb(dir string) (Database, error) {
|
||||
func OpenPrototypeDatabase(dir string) (Database, error) {
|
||||
if dir == "" {
|
||||
return nil, fmt.Errorf("database path is empty. did you set it in config file?")
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ func (db *PrototypeDb) StoreSelfStatus(status EventType, when time.Time) error {
|
|||
defer db.mutex.Unlock()
|
||||
|
||||
if status != EventSelfUp && status != EventSelfDown {
|
||||
log.Panicf("(StoreSelfStatus) invalid value: %v", status)
|
||||
return fmt.Errorf("(StoreSelfStatus) invalid value: %v", status)
|
||||
}
|
||||
var placeholder ServiceStatus
|
||||
new_row := Row{when, EventType(status), placeholder}
|
||||
|
|
9
main.go
9
main.go
|
@ -111,7 +111,7 @@ func indexForBrowserWithHistoricalData(w http.ResponseWriter, _ *http.Request, h
|
|||
//
|
||||
// reference: see `indexForBrowser` above
|
||||
|
||||
parsedTemplate, err := parseAndRenderTemplate("templates/index.html", siteName, iconSrc, data)
|
||||
parsedTemplate, err := parseAndRenderTemplate("templates/index.html", siteName, iconSrc, historical_data)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
|
@ -137,7 +137,7 @@ func main() {
|
|||
log.Panic(err)
|
||||
}
|
||||
|
||||
dbm, err = core.OpenDatabase(config.Database)
|
||||
dbm, err = core.OpenPrototypeDatabase(config.Database)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
|
@ -177,7 +177,10 @@ func main() {
|
|||
addr = unix_socket_path
|
||||
|
||||
// VnPower: is this unsafe?
|
||||
removeFile(addr) // ideally this should be run at program exit. sadly Go's defer doesn't care about signals or panic
|
||||
err = removeFileIfExist(addr) // ideally this should be run at program exit. sadly Go's defer doesn't care about signals or panic
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
srv := &http.Server{Addr: addr, Handler: nil}
|
||||
|
|
6
util.go
6
util.go
|
@ -1,13 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
func removeFile(path string) {
|
||||
func removeFileIfExist(path string) error {
|
||||
err := os.Remove(path)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
log.Panic(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue