cleanup the database on restart to remove stuck jobs
This commit is contained in:
parent
45d28b7bc1
commit
43894050b5
1 changed files with 8 additions and 0 deletions
|
@ -83,6 +83,7 @@ func Open(driver, config string) *sql.DB {
|
|||
log.Errorln(err)
|
||||
log.Fatalln("migration failed")
|
||||
}
|
||||
cleanupDatabase(db)
|
||||
return db
|
||||
}
|
||||
|
||||
|
@ -128,6 +129,13 @@ func setupDatabase(driver string, db *sql.DB) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// helper function to avoid stuck jobs when Drone unexpectedly
|
||||
// restarts. This is a temp fix for https://github.com/drone/drone/issues/1195
|
||||
func cleanupDatabase(db *sql.DB) {
|
||||
db.Exec("update builds set build_status = 'error' where build_status IN ('pending','running')")
|
||||
db.Exec("update jobs set job_status = 'error' where job_status IN ('pending','running')")
|
||||
}
|
||||
|
||||
// helper function to setup the meddler default driver
|
||||
// based on the selected driver name.
|
||||
func setupMeddler(driver string) {
|
||||
|
|
Loading…
Reference in a new issue