Files
lnd.xprv/cmd/lnd/main.go
T

41 lines
979 B
Go
Raw Normal View History

2019-01-24 14:28:25 +01:00
package main
import (
"fmt"
"os"
2020-04-30 09:42:28 +02:00
"github.com/jessevdk/go-flags"
2019-01-24 14:28:25 +01:00
"github.com/lightningnetwork/lnd"
2020-04-30 09:42:28 +02:00
"github.com/lightningnetwork/lnd/signal"
2019-01-24 14:28:25 +01:00
)
func main() {
2020-04-30 09:39:29 +02:00
// Load the configuration, and parse any command line options. This
// function will also set up logging properly.
loadedConfig, err := lnd.LoadConfig()
if err != nil {
if e, ok := err.(*flags.Error); !ok || e.Type != flags.ErrHelp {
// Print error if not due to help request.
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
// Help was requested, exit normally.
os.Exit(0)
2020-04-30 09:39:29 +02:00
}
2020-04-30 09:42:28 +02:00
// Hook interceptor for os signals.
if err := signal.Intercept(); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
2020-04-30 09:42:28 +02:00
2019-01-24 14:28:25 +01:00
// Call the "real" main in a nested manner so the defers will properly
// be executed in the case of a graceful shutdown.
if err := lnd.Main(
2020-04-30 09:42:28 +02:00
loadedConfig, lnd.ListenerCfg{}, signal.ShutdownChannel(),
); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
2019-01-24 14:28:25 +01:00
os.Exit(1)
}
}