mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 12:30:41 +01:00
feat(be): timeout of boltdb
This commit is contained in:
parent
f207aa6bff
commit
6bd6c338f7
@ -13,6 +13,7 @@ import (
|
||||
"github.com/gorilla/context"
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/spf13/cobra"
|
||||
"go.etcd.io/bbolt"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
@ -110,7 +111,12 @@ func createStore() db.Store {
|
||||
store := factory.CreateStore()
|
||||
|
||||
if err := store.Connect(); err != nil {
|
||||
fmt.Println("\n Have you run `semaphore setup`?")
|
||||
switch err {
|
||||
case bbolt.ErrTimeout:
|
||||
fmt.Println("\n [ERR_BOLTDB_TIMEOUT] BoltDB supports only one connection at a time. You should stop service when using CLI.")
|
||||
default:
|
||||
fmt.Println("\n Have you run `semaphore setup`?")
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"go.etcd.io/bbolt"
|
||||
"reflect"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
||||
const MaxID = 2147483647
|
||||
@ -79,7 +80,10 @@ func (d *BoltDb) Connect() error {
|
||||
}
|
||||
|
||||
var err error
|
||||
d.db, err = bbolt.Open(filename, 0666, nil)
|
||||
d.db, err = bbolt.Open(filename, 0666, &bbolt.Options{
|
||||
Timeout: 5 * time.Second,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user