mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-21 17:01:04 +01:00
fix(runner): delete running for boltdb
This commit is contained in:
parent
c9705d2df3
commit
216099d144
6
.devcontainer/config-runner.json
Normal file
6
.devcontainer/config-runner.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"web_host": "http://localhost:3000",
|
||||
"runner": {
|
||||
"token_file": "/home/codespace/.semaphore-runner-token"
|
||||
}
|
||||
}
|
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@ -12,6 +12,19 @@
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder}/.venv/bin:${env:PATH}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Launch Server with remote Runner",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"program": "./cli/main.go",
|
||||
"args": ["server", "--config", ".devcontainer/config.json"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"PATH": "${workspaceFolder}/.venv/bin:${env:PATH}",
|
||||
"SEMAPHORE_USE_REMOTE_RUNNER": "true"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
package bolt
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/ansible-semaphore/semaphore/db"
|
||||
"github.com/ansible-semaphore/semaphore/util"
|
||||
"github.com/gorilla/securecookie"
|
||||
"go.etcd.io/bbolt"
|
||||
)
|
||||
|
||||
func (d *BoltDb) GetRunner(projectID int, runnerID int) (runner db.Runner, err error) {
|
||||
@ -47,7 +50,7 @@ func (d *BoltDb) GetGlobalRunner(runnerID int) (runner db.Runner, err error) {
|
||||
|
||||
func (d *BoltDb) GetGlobalRunners(activeOnly bool) (runners []db.Runner, err error) {
|
||||
err = d.getObjects(0, db.GlobalRunnerProps, db.RetrieveQueryParams{}, func(i interface{}) bool {
|
||||
runner := i.(*db.Runner)
|
||||
runner := i.(db.Runner)
|
||||
if activeOnly {
|
||||
return runner.Active
|
||||
}
|
||||
@ -57,7 +60,9 @@ func (d *BoltDb) GetGlobalRunners(activeOnly bool) (runners []db.Runner, err err
|
||||
}
|
||||
|
||||
func (d *BoltDb) DeleteGlobalRunner(runnerID int) (err error) {
|
||||
return
|
||||
return d.db.Update(func(tx *bbolt.Tx) error {
|
||||
return d.deleteObject(0, db.GlobalRunnerProps, intObjectID(runnerID), tx)
|
||||
})
|
||||
}
|
||||
|
||||
func (d *BoltDb) UpdateRunner(runner db.Runner) (err error) {
|
||||
@ -65,7 +70,7 @@ func (d *BoltDb) UpdateRunner(runner db.Runner) (err error) {
|
||||
}
|
||||
|
||||
func (d *BoltDb) CreateRunner(runner db.Runner) (newRunner db.Runner, err error) {
|
||||
runner.Token = util.RandString(12)
|
||||
runner.Token = base64.StdEncoding.EncodeToString(securecookie.GenerateRandomKey(32))
|
||||
|
||||
res, err := d.createObject(0, db.GlobalRunnerProps, runner)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user