Files
ark/server/cmd/arkd/main.go
Pietralberto Mazza dc00d60585 Rename folders (#97)
* Rename arkd folder & drop cli

* Rename ark cli folder & update docs

* Update readme

* Fix

* scripts: add build-all

* Add target to build cli for all platforms

* Update build scripts

---------

Co-authored-by: tiero <3596602+tiero@users.noreply.github.com>
2024-02-09 19:32:58 +01:00

71 lines
1.6 KiB
Go
Executable File

package main
import (
"os"
"os/signal"
"syscall"
appconfig "github.com/ark-network/ark/internal/app-config"
"github.com/ark-network/ark/internal/config"
grpcservice "github.com/ark-network/ark/internal/interface/grpc"
log "github.com/sirupsen/logrus"
)
//nolint:all
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
cfg, err := config.LoadConfig()
if err != nil {
log.WithError(err).Fatal("invalid config")
}
log.SetLevel(log.Level(cfg.LogLevel))
svcConfig := grpcservice.Config{
Port: cfg.Port,
NoTLS: cfg.NoTLS,
}
if cfg.RoundLifetime%512 != 0 {
setLifetime := cfg.RoundLifetime
cfg.RoundLifetime = cfg.RoundLifetime - (cfg.RoundLifetime % 512)
log.Infof("round lifetime must be a multiple of 512, %d -> %d", setLifetime, cfg.RoundLifetime)
}
appConfig := &appconfig.Config{
DbType: cfg.DbType,
DbDir: cfg.DbDir,
RoundInterval: cfg.RoundInterval,
Network: cfg.Network,
SchedulerType: cfg.SchedulerType,
TxBuilderType: cfg.TxBuilderType,
BlockchainScannerType: cfg.BlockchainScannerType,
WalletAddr: cfg.WalletAddr,
MinRelayFee: cfg.MinRelayFee,
RoundLifetime: cfg.RoundLifetime,
}
svc, err := grpcservice.NewService(svcConfig, appConfig)
if err != nil {
log.Fatal(err)
}
log.RegisterExitHandler(svc.Stop)
log.Info("starting service...")
if err := svc.Start(); err != nil {
log.Fatal(err)
}
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT)
<-sigChan
log.Info("shutting down service...")
log.Exit(0)
}