Add API endpoint to pause a worker

This commit is contained in:
simon987
2019-05-05 19:09:45 -04:00
parent 8f10567bd0
commit 72c8e18044
8 changed files with 378 additions and 231 deletions

View File

@@ -9,6 +9,7 @@ type Worker struct {
Created int64 `json:"created"`
Alias string `json:"alias,omitempty"`
Secret []byte `json:"secret"`
Paused bool `json:"paused"`
}
type WorkerStats struct {
@@ -96,8 +97,8 @@ func (database *Database) GrantAccess(workerId int64, projectId int64) bool {
func (database *Database) UpdateWorker(worker *Worker) bool {
db := database.getDB()
res, err := db.Exec(`UPDATE worker SET alias=$1 WHERE id=$2`,
worker.Alias, worker.Id)
res, err := db.Exec(`UPDATE worker SET alias=$1, paused=$2 WHERE id=$3`,
worker.Alias, worker.Paused, worker.Id)
handleErr(err)
rowsAffected, _ := res.RowsAffected()