mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-13 12:33:04 +02:00
38 lines
922 B
Go
38 lines
922 B
Go
package pool
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"github.com/lightningnetwork/lnd/build"
|
|
"github.com/lightningnetwork/lnd/signal"
|
|
)
|
|
|
|
// Run starts the trader daemon and blocks until it's shut down again.
|
|
func Run(cfg *Config) error {
|
|
// Append the network type to the log directory so it is
|
|
// "namespaced" per network in the same fashion as the data directory.
|
|
cfg.LogDir = filepath.Join(cfg.LogDir, cfg.Network)
|
|
|
|
// Initialize logging at the default logging level.
|
|
err := logWriter.InitLogRotator(
|
|
filepath.Join(cfg.LogDir, DefaultLogFilename),
|
|
cfg.MaxLogFileSize, cfg.MaxLogFiles,
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = build.ParseAndSetDebugLevels(cfg.DebugLevel, logWriter)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
signal.Intercept()
|
|
trader := NewServer(cfg)
|
|
err = trader.Start()
|
|
if err != nil {
|
|
return fmt.Errorf("unable to start server: %v", err)
|
|
}
|
|
<-signal.ShutdownChannel()
|
|
return trader.Stop()
|
|
}
|