mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-14 10:06:40 +00:00

* [NOD-487] Implement a mechanism to gracefully shut down after a panic. * [NOD-487] Fixed bad log. * [NOD-487] Removed unused import. * [NOD-487] Convert panic handlers from anonymous functions to methods.
47 lines
848 B
Go
47 lines
848 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/daglabs/btcd/signal"
|
|
"github.com/daglabs/btcd/util/panics"
|
|
)
|
|
|
|
func main() {
|
|
defer panics.HandlePanic(log, nil, nil)
|
|
cfg, err := parseConfig()
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error parsing command-line arguments: %s", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if cfg.Verbose {
|
|
enableRPCLogging()
|
|
}
|
|
|
|
connManager, err := newConnectionManager(cfg)
|
|
if err != nil {
|
|
panic(errors.Errorf("Error initializing connection manager: %s", err))
|
|
}
|
|
defer connManager.close()
|
|
|
|
spawn(func() {
|
|
err = mineLoop(connManager, cfg.BlockDelay)
|
|
if err != nil {
|
|
panic(errors.Errorf("Error in main loop: %s", err))
|
|
}
|
|
})
|
|
|
|
interrupt := signal.InterruptListener()
|
|
<-interrupt
|
|
}
|
|
|
|
func disconnect(clients []*simulatorClient) {
|
|
for _, client := range clients {
|
|
client.Disconnect()
|
|
}
|
|
}
|