1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

feat: show data loss warning (resolve #38)

This commit is contained in:
Ferdinand Mütsch 2020-08-23 13:30:04 +02:00
parent 11d1d5bc99
commit 0af7d2f8ef
2 changed files with 14 additions and 1 deletions

13
main.go
View File

@ -43,6 +43,11 @@ func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile) log.SetFlags(log.LstdFlags | log.Lshortfile)
} }
// Show data loss warning
if config.CleanUp {
promptAbort("`CLEANUP` is set to `true`, which may cause data loss. Are you sure to continue?", 5)
}
// Connect to database // Connect to database
var err error var err error
db, err = gorm.Open(config.DbDialect, utils.MakeConnectionString(config)) db, err = gorm.Open(config.DbDialect, utils.MakeConnectionString(config))
@ -172,3 +177,11 @@ func migrateLanguages() {
} }
} }
} }
func promptAbort(message string, timeoutSec int) {
log.Printf("[WARNING] %s.\nTo abort server startup, press Ctrl+C.\n", message)
for i := timeoutSec; i > 0; i-- {
log.Printf("Starting in %d seconds ...\n", i)
time.Sleep(1 * time.Second)
}
}

View File

@ -1 +1 @@
1.7.3 1.7.4