2019-01-24 16:28:25 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
2020-04-30 10:42:28 +03:00
|
|
|
"github.com/jessevdk/go-flags"
|
2019-01-24 16:28:25 +03:00
|
|
|
"github.com/lightningnetwork/lnd"
|
2020-04-30 10:42:28 +03:00
|
|
|
"github.com/lightningnetwork/lnd/signal"
|
2019-01-24 16:28:25 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-04-30 10:39:29 +03: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 {
|
|
|
|
_, _ = fmt.Fprintln(os.Stderr, err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2020-04-30 10:42:28 +03:00
|
|
|
// Hook interceptor for os signals.
|
2020-08-24 09:54:34 +03:00
|
|
|
if err := signal.Intercept(); err != nil {
|
|
|
|
_, _ = fmt.Fprintln(os.Stderr, err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
2020-04-30 10:42:28 +03:00
|
|
|
|
2019-01-24 16:28:25 +03:00
|
|
|
// Call the "real" main in a nested manner so the defers will properly
|
|
|
|
// be executed in the case of a graceful shutdown.
|
2020-04-30 10:42:28 +03:00
|
|
|
err = lnd.Main(
|
|
|
|
loadedConfig, lnd.ListenerCfg{}, signal.ShutdownChannel(),
|
|
|
|
)
|
|
|
|
if err != nil {
|
2019-01-24 16:28:25 +03:00
|
|
|
if e, ok := err.(*flags.Error); ok && e.Type == flags.ErrHelp {
|
|
|
|
} else {
|
2020-04-30 10:39:29 +03:00
|
|
|
_, _ = fmt.Fprintln(os.Stderr, err)
|
2019-01-24 16:28:25 +03:00
|
|
|
}
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|