Compare commits

..

1 Commits

Author SHA1 Message Date
5fc5f5fd5d chore: add jenkins pipeline
Some checks failed
arcad/emissary/pipeline/head There was a failure building this commit
2023-03-31 17:00:08 +02:00
6 changed files with 15 additions and 24 deletions

1
Jenkinsfile vendored
View File

@ -23,7 +23,6 @@ pipeline {
sh ''' sh '''
git config --global credential.https://forge.cadoles.com.username "$GIT_USERNAME" git config --global credential.https://forge.cadoles.com.username "$GIT_USERNAME"
git config --global credential.https://forge.cadoles.com.helper '!f() { test "$1" = get && echo "password=$GIT_PASSWORD"; }; f' git config --global credential.https://forge.cadoles.com.helper '!f() { test "$1" = get && echo "password=$GIT_PASSWORD"; }; f'
export GOPRIVATE=forge.cadoles.com/arcad/edge export GOPRIVATE=forge.cadoles.com/arcad/edge
make test make test
''' '''

View File

@ -28,8 +28,6 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
const defaultSQLiteParams = "?_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_txlock=immediate"
func (c *Controller) getHandlerOptions(ctx context.Context, appKey string, specs *spec.Spec) ([]edgeHTTP.HandlerOptionFunc, error) { func (c *Controller) getHandlerOptions(ctx context.Context, appKey string, specs *spec.Spec) ([]edgeHTTP.HandlerOptionFunc, error) {
dataDir, err := c.ensureAppDataDir(ctx, appKey) dataDir, err := c.ensureAppDataDir(ctx, appKey)
if err != nil { if err != nil {
@ -37,7 +35,7 @@ func (c *Controller) getHandlerOptions(ctx context.Context, appKey string, specs
} }
dbFile := filepath.Join(dataDir, appKey+".sqlite") dbFile := filepath.Join(dataDir, appKey+".sqlite")
db, err := sqlite.Open(dbFile + defaultSQLiteParams) db, err := sqlite.Open(dbFile)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "could not open database file '%s'", dbFile) return nil, errors.Wrapf(err, "could not open database file '%s'", dbFile)
} }

View File

@ -35,15 +35,12 @@ type Server struct {
} }
func (s *Server) Start(ctx context.Context, addr string) (err error) { func (s *Server) Start(ctx context.Context, addr string) (err error) {
if s.Running() { if s.server != nil {
if err := s.Stop(); err != nil { if err := s.Stop(); err != nil {
return errors.WithStack(err) return errors.WithStack(err)
} }
} }
s.serverMutex.Lock()
defer s.serverMutex.Unlock()
router := chi.NewRouter() router := chi.NewRouter()
router.Use(middleware.Logger) router.Use(middleware.Logger)
@ -88,7 +85,9 @@ func (s *Server) Start(ctx context.Context, addr string) (err error) {
} }
}() }()
s.serverMutex.Lock()
s.server = server s.server = server
s.serverMutex.Unlock()
return nil return nil
} }
@ -101,25 +100,20 @@ func (s *Server) Running() bool {
} }
func (s *Server) Stop() error { func (s *Server) Stop() error {
if !s.Running() {
return nil
}
s.serverMutex.Lock()
defer s.serverMutex.Unlock()
if s.server == nil { if s.server == nil {
return nil return nil
} }
if err := s.server.Close(); err != nil { defer func() {
s.serverMutex.Lock()
s.server = nil s.server = nil
s.serverMutex.Unlock()
}()
if err := s.server.Close(); err != nil {
return errors.WithStack(err) return errors.WithStack(err)
} }
s.server = nil
return nil return nil
} }

View File

@ -49,6 +49,10 @@ func RunCommand() *cli.Command {
controllers = append(controllers, spec.NewController()) controllers = append(controllers, spec.NewController())
} }
if ctrlConf.Proxy.Enabled {
controllers = append(controllers, proxy.NewController())
}
if ctrlConf.UCI.Enabled { if ctrlConf.UCI.Enabled {
controllers = append(controllers, openwrt.NewUCIController( controllers = append(controllers, openwrt.NewUCIController(
string(ctrlConf.UCI.BinPath), string(ctrlConf.UCI.BinPath),
@ -62,10 +66,6 @@ func RunCommand() *cli.Command {
)) ))
} }
if ctrlConf.Proxy.Enabled {
controllers = append(controllers, proxy.NewController())
}
if ctrlConf.SysUpgrade.Enabled { if ctrlConf.SysUpgrade.Enabled {
sysUpgradeArgs := make([]string, 0) sysUpgradeArgs := make([]string, 0)
if len(ctrlConf.SysUpgrade.SysUpgradeCommand) > 1 { if len(ctrlConf.SysUpgrade.SysUpgradeCommand) > 1 {

View File

@ -15,6 +15,6 @@ type DatabaseConfig struct {
func NewDefaultDatabaseConfig() DatabaseConfig { func NewDefaultDatabaseConfig() DatabaseConfig {
return DatabaseConfig{ return DatabaseConfig{
Driver: "sqlite", Driver: "sqlite",
DSN: "sqlite://emissary.sqlite?_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_txlock=immediate", DSN: "sqlite://emissary.sqlite?_fk=true&_journal=WAL",
} }
} }

View File

@ -9,7 +9,7 @@ server:
port: 3000 port: 3000
database: database:
driver: sqlite driver: sqlite
dsn: sqlite:///var/lib/emissary/data.sqlite?_pragma=foreign_keys(1)&_pragma=journal_mode(WAL)&_txlock=immediate dsn: sqlite:///var/lib/emissary/data.sqlite?_fk=true&_journal=WAL
cors: cors:
allowedOrigins: [] allowedOrigins: []
allowCredentials: true allowCredentials: true