Compare commits
No commits in common. "50c192ce69e659c067e4b522be836f884705e2a7" and "ab673a0f2d66cd2f6c95d5fd4b144afcb4d74e5c" have entirely different histories.
50c192ce69
...
ab673a0f2d
|
|
@ -13,7 +13,7 @@ steps:
|
||||||
- export CGO_ENABLED=0
|
- export CGO_ENABLED=0
|
||||||
- apk --no-cache add git
|
- apk --no-cache add git
|
||||||
- go get -d -t ./...
|
- go get -d -t ./...
|
||||||
- go build ./...
|
- go build p83.nl/go/ekster/cmd/eksterd
|
||||||
- go test ./...
|
- go test ./...
|
||||||
|
|
||||||
- name: publish-personal
|
- name: publish-personal
|
||||||
|
|
|
||||||
|
|
@ -116,11 +116,7 @@ func NewApp(options AppOptions) (*App, error) {
|
||||||
options: options,
|
options: options,
|
||||||
}
|
}
|
||||||
|
|
||||||
backend, err := loadMemoryBackend(options.pool)
|
app.backend = loadMemoryBackend(options.pool)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
app.backend = backend
|
|
||||||
app.backend.AuthEnabled = options.AuthEnabled
|
app.backend.AuthEnabled = options.AuthEnabled
|
||||||
app.backend.baseURL = options.BaseURL
|
app.backend.baseURL = options.BaseURL
|
||||||
app.backend.hubIncomingBackend.pool = options.pool
|
app.backend.hubIncomingBackend.pool = options.pool
|
||||||
|
|
@ -203,10 +199,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if createBackend {
|
if createBackend {
|
||||||
err := createMemoryBackend()
|
createMemoryBackend()
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Error while saving backend.json: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(peter): automatically gather this information from login or otherwise
|
// TODO(peter): automatically gather this information from login or otherwise
|
||||||
log.Println(`Config file "backend.json" is created in the current directory.`)
|
log.Println(`Config file "backend.json" is created in the current directory.`)
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"p83.nl/go/ekster/pkg/auth"
|
"p83.nl/go/ekster/pkg/auth"
|
||||||
"p83.nl/go/ekster/pkg/fetch"
|
"p83.nl/go/ekster/pkg/fetch"
|
||||||
"p83.nl/go/ekster/pkg/microsub"
|
"p83.nl/go/ekster/pkg/microsub"
|
||||||
|
|
@ -91,7 +90,7 @@ func (b *memoryBackend) load() error {
|
||||||
filename := "backend.json"
|
filename := "backend.json"
|
||||||
f, err := os.Open(filename)
|
f, err := os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
panic("cant open backend.json")
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
jw := json.NewDecoder(f)
|
jw := json.NewDecoder(f)
|
||||||
|
|
@ -120,31 +119,30 @@ func (b *memoryBackend) refreshChannels() {
|
||||||
b.lock.RUnlock()
|
b.lock.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *memoryBackend) save() error {
|
func (b *memoryBackend) save() {
|
||||||
filename := "backend.json"
|
filename := "backend.json"
|
||||||
f, err := os.Create(filename)
|
f, _ := os.Create(filename)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
jw := json.NewEncoder(f)
|
jw := json.NewEncoder(f)
|
||||||
jw.SetIndent("", " ")
|
jw.SetIndent("", " ")
|
||||||
b.lock.RLock()
|
b.lock.RLock()
|
||||||
defer b.lock.RUnlock()
|
defer b.lock.RUnlock()
|
||||||
return jw.Encode(b)
|
jw.Encode(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadMemoryBackend(pool *redis.Pool) (*memoryBackend, error) {
|
func loadMemoryBackend(pool *redis.Pool) *memoryBackend {
|
||||||
backend := &memoryBackend{pool: pool}
|
backend := &memoryBackend{pool: pool}
|
||||||
err := backend.load()
|
err := backend.load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "while loading backend")
|
log.Printf("Error while loadingbackend: %v\n", err)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
backend.refreshChannels()
|
backend.refreshChannels()
|
||||||
return backend, nil
|
|
||||||
|
return backend
|
||||||
}
|
}
|
||||||
|
|
||||||
func createMemoryBackend() error {
|
func createMemoryBackend() {
|
||||||
backend := memoryBackend{}
|
backend := memoryBackend{}
|
||||||
backend.lock.Lock()
|
backend.lock.Lock()
|
||||||
|
|
||||||
|
|
@ -165,7 +163,7 @@ func createMemoryBackend() error {
|
||||||
|
|
||||||
backend.lock.Unlock()
|
backend.lock.Unlock()
|
||||||
|
|
||||||
return backend.save()
|
backend.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelsGetList gets channels
|
// ChannelsGetList gets channels
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user