mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-23 06:46:15 -06:00
[bugfix] Return useful err on server start failure
This commit is contained in:
parent
829143d263
commit
85d4994b96
5 changed files with 73 additions and 50 deletions
7
internal/cache/cache.go
vendored
7
internal/cache/cache.go
vendored
|
|
@ -136,6 +136,13 @@ func (c *Caches) Start() {
|
|||
})
|
||||
}
|
||||
|
||||
// Inited returns true if the
|
||||
// caches have been initialized.
|
||||
func (c *Caches) Inited() bool {
|
||||
// Use nilness of *ttl.Cache pointers as heuristic.
|
||||
return c.Webfinger != nil && c.StatusesFilterableFields != nil
|
||||
}
|
||||
|
||||
// Stop will stop any caches that require a background
|
||||
// routine, which usually means any kind of TTL caches.
|
||||
func (c *Caches) Stop() {
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
// GoToSocial
|
||||
// Copyright (C) GoToSocial Authors admin@gotosocial.org
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/log"
|
||||
)
|
||||
|
||||
func MustParseIPPrefixes(in []string) []netip.Prefix {
|
||||
prefs := make([]netip.Prefix, 0, len(in))
|
||||
|
||||
for _, i := range in {
|
||||
pref, err := netip.ParsePrefix(i)
|
||||
if err != nil {
|
||||
log.Panicf(nil, "error parsing ip prefix from %q: %v", i, err)
|
||||
}
|
||||
|
||||
prefs = append(prefs, pref)
|
||||
}
|
||||
|
||||
return prefs
|
||||
}
|
||||
|
|
@ -44,6 +44,11 @@ func (sch *Scheduler) Start() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// Started returns true if the scheduler has been started.
|
||||
func (sch *Scheduler) Started() bool {
|
||||
return sch.ts != nil
|
||||
}
|
||||
|
||||
// Stop attempts to stop scheduler, cancelling
|
||||
// all running tasks. Returns false if not running.
|
||||
func (sch *Scheduler) Stop() bool {
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ import (
|
|||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/netip"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/superseriousbusiness/gotosocial/internal/config"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/httpclient"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/queue"
|
||||
"github.com/superseriousbusiness/gotosocial/internal/transport/delivery"
|
||||
|
|
@ -44,11 +44,8 @@ func TestDeliveryWorkerPool(t *testing.T) {
|
|||
|
||||
func testDeliveryWorkerPool(t *testing.T, sz int, input []*testrequest) {
|
||||
wp := new(delivery.WorkerPool)
|
||||
wp.Init(httpclient.New(httpclient.Config{
|
||||
AllowRanges: config.MustParseIPPrefixes([]string{
|
||||
"127.0.0.0/8",
|
||||
}),
|
||||
}))
|
||||
allowLocal := []netip.Prefix{netip.MustParsePrefix("127.0.0.0/8")}
|
||||
wp.Init(httpclient.New(httpclient.Config{AllowRanges: allowLocal}))
|
||||
wp.Start(sz)
|
||||
defer wp.Stop()
|
||||
test(t, &wp.Queue, input)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue