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-08-28 12:18:15 +03:00
|
|
|
// Hook interceptor for os signals.
|
|
|
|
shutdownInterceptor, err := signal.Intercept()
|
|
|
|
if err != nil {
|
|
|
|
_, _ = fmt.Fprintln(os.Stderr, err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
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.
|
2020-08-28 12:18:15 +03:00
|
|
|
loadedConfig, err := lnd.LoadConfig(shutdownInterceptor)
|
2020-04-30 10:39:29 +03:00
|
|
|
if err != nil {
|
2020-09-08 18:05:16 +03:00
|
|
|
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 10:39:29 +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-08-28 12:18:15 +03:00
|
|
|
if err = lnd.Main(
|
|
|
|
loadedConfig, lnd.ListenerCfg{}, shutdownInterceptor,
|
2020-09-08 18:05:16 +03:00
|
|
|
); err != nil {
|
|
|
|
_, _ = fmt.Fprintln(os.Stderr, err)
|
2019-01-24 16:28:25 +03:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|