diff --git a/packages/shutdown/order.go b/packages/shutdown/order.go index c00add7e5b035f8ff592b86aa3e2af1ba1369e83..957eb1526f11b9226ca83150457f513180acdc37 100644 --- a/packages/shutdown/order.go +++ b/packages/shutdown/order.go @@ -1,17 +1,17 @@ package shutdown const ( - ShutdownPriorityDatabase = iota - ShutdownPriorityFPC - ShutdownPriorityTangle - ShutdownPriorityRemoteLog - ShutdownPriorityAnalysis - ShutdownPriorityMetrics - ShutdownPriorityAutopeering - ShutdownPriorityGossip - ShutdownPriorityWebAPI - ShutdownPrioritySPA - ShutdownPriorityGraph - ShutdownPrioritySpammer - ShutdownPriorityBadgerGarbageCollection + PriorityDatabase = iota + PriorityFPC + PriorityTangle + PriorityRemoteLog + PriorityAnalysis + PriorityMetrics + PriorityAutopeering + PriorityGossip + PriorityWebAPI + PrioritySPA + PriorityGraph + PrioritySpammer + PriorityBadgerGarbageCollection ) diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index b1344f7ed8ce26d8c66f57bff76af1eec75830df..18c8fa6ce470095eed6b3806ca97f37b4f45bcff 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -55,7 +55,7 @@ func Run(plugin *node.Plugin) { } } } - }, shutdown.ShutdownPriorityAnalysis) + }, shutdown.PriorityAnalysis) } func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers { diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index bfd7296dc62a73c6866b08aea6d0e9f5f32f5bbf..2f13eb6f637341c247b931b854c421a64285f37a 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -50,7 +50,7 @@ func Run(plugin *node.Plugin) { go server.Listen("0.0.0.0", config.Node.GetInt(CFG_SERVER_PORT)) <-shutdownSignal Shutdown() - }, shutdown.ShutdownPriorityAnalysis) + }, shutdown.PriorityAnalysis) } func Shutdown() { diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index 6141625f8b4eb71af0b95341ec3edf993239f6c7..dba2815cbb04c8c484d38feac12e17fd631f8c18 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -47,7 +47,7 @@ func Configure() { func Run() { log.Infof("Starting %s ...", name) - if err := daemon.BackgroundWorker(name, start, shutdown.ShutdownPriorityAnalysis); err != nil { + if err := daemon.BackgroundWorker(name, start, shutdown.PriorityAnalysis); err != nil { log.Errorf("Error starting as daemon: %s", err) } } diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index c8e5003ad59db51b8beb0af41d2698a22b580f6f..e84cac5b7ed2b730bb65b25cad4bebe1b9ac9900 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -26,7 +26,7 @@ func configure(*node.Plugin) { } func run(*node.Plugin) { - if err := daemon.BackgroundWorker(name, start, shutdown.ShutdownPriorityAutopeering); err != nil { + if err := daemon.BackgroundWorker(name, start, shutdown.PriorityAutopeering); err != nil { log.Errorf("Failed to start as daemon: %s", err) } } diff --git a/plugins/database/plugin.go b/plugins/database/plugin.go index 3762d8f0d5cb5772cc80fdf82fe69f248ec5e69a..c9c279c9a29a0a2223994adbdf75f5e23bb72d91 100644 --- a/plugins/database/plugin.go +++ b/plugins/database/plugin.go @@ -34,12 +34,12 @@ func run(plugin *node.Plugin) { timeutil.Ticker(func() { database.CleanupBadgerInstance(log) }, 5*time.Minute, shutdownSignal) - }, shutdown.ShutdownPriorityBadgerGarbageCollection) + }, shutdown.PriorityBadgerGarbageCollection) daemon.BackgroundWorker(PLUGIN_NAME, func(shutdownSignal <-chan struct{}) { <-shutdownSignal log.Infof("Syncing database to disk...") database.GetBadgerInstance().Close() log.Infof("Syncing database to disk... done") - }, shutdown.ShutdownPriorityDatabase) + }, shutdown.PriorityDatabase) } diff --git a/plugins/fpc/plugin.go b/plugins/fpc/plugin.go index 8d9e55b0a73e0aa3f16f977f73096ebfe1507ab2..cf57b6f446391e56c76cce0f4d4bf2af9a40e96d 100644 --- a/plugins/fpc/plugin.go +++ b/plugins/fpc/plugin.go @@ -101,7 +101,7 @@ func run(_ *node.Plugin) { <-shutdownSignal voterServer.Shutdown() log.Info("Stopped vote server") - }, shutdown.ShutdownPriorityFPC) + }, shutdown.PriorityFPC) daemon.BackgroundWorker("FPCRoundsInitiator", func(shutdownSignal <-chan struct{}) { log.Infof("Started FPC round initiator") @@ -119,7 +119,7 @@ func run(_ *node.Plugin) { } } log.Infof("Stopped FPC round initiator") - }, shutdown.ShutdownPriorityFPC) + }, shutdown.PriorityFPC) } // PeerOpinionGiver implements the OpinionGiver interface based on a peer. diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 37c4f064fcbe33abfe1d33c6ef194f60dc8ef1ca..408665afb26f5bcc38a2eb6fd996d371d172c133 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -27,7 +27,7 @@ func configure(*node.Plugin) { } func run(*node.Plugin) { - if err := daemon.BackgroundWorker(name, start, shutdown.ShutdownPriorityGossip); err != nil { + if err := daemon.BackgroundWorker(name, start, shutdown.PriorityGossip); err != nil { log.Errorf("Failed to start as daemon: %s", err) } } diff --git a/plugins/graph/plugin.go b/plugins/graph/plugin.go index f71c4ad692e396df2b610e87d1ddbdab51a0c3ee..f36a9c99f4b5c9ef516a606d6fd611ca7fec94c6 100644 --- a/plugins/graph/plugin.go +++ b/plugins/graph/plugin.go @@ -108,7 +108,7 @@ func run(*node.Plugin) { messagelayer.Tangle.Events.TransactionAttached.Detach(notifyNewTx) newTxWorkerPool.Stop() log.Info("Stopping Graph[NewTxWorker] ... done") - }, shutdown.ShutdownPriorityGraph) + }, shutdown.PriorityGraph) daemon.BackgroundWorker("Graph Webserver", func(shutdownSignal <-chan struct{}) { go socketioServer.Serve() @@ -141,5 +141,5 @@ func run(*node.Plugin) { log.Errorf("Error closing Socket.IO server: %s", err) } log.Info("Stopping Graph Webserver ... done") - }, shutdown.ShutdownPriorityGraph) + }, shutdown.PriorityGraph) } diff --git a/plugins/messagelayer/plugin.go b/plugins/messagelayer/plugin.go index 7e0ad510256e4cc765b7311a07d291baa56319b9..7207b0be875f2ffd6e7f06344f124633afbe9579 100644 --- a/plugins/messagelayer/plugin.go +++ b/plugins/messagelayer/plugin.go @@ -86,5 +86,5 @@ func run(*node.Plugin) { MessageFactory.Shutdown() TransactionParser.Shutdown() Tangle.Shutdown() - }, shutdown.ShutdownPriorityTangle) + }, shutdown.PriorityTangle) } diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index a07160af3d5e560cbfe12139151ed87decad0512..2e315eab2448a1ac4666e944fcaf0c0c438e4ee2 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -30,5 +30,5 @@ func run(plugin *node.Plugin) { // create a background worker that "measures" the TPS value every second daemon.BackgroundWorker("Metrics TPS Updater", func(shutdownSignal <-chan struct{}) { timeutil.Ticker(measureReceivedTPS, 1*time.Second, shutdownSignal) - }, shutdown.ShutdownPriorityMetrics) + }, shutdown.PriorityMetrics) } diff --git a/plugins/remotelog/plugin.go b/plugins/remotelog/plugin.go index cc241e6cdabab7dc3754158c24a68c905dfb8317..9622b0af565b852a0476f9c61b16608dbe3df0a2 100644 --- a/plugins/remotelog/plugin.go +++ b/plugins/remotelog/plugin.go @@ -96,7 +96,7 @@ func run(plugin *node.Plugin) { logger.Events.AnyMsg.Detach(logEvent) workerPool.Stop() log.Infof("Stopping %s ... done", PLUGIN_NAME) - }, shutdown.ShutdownPriorityRemoteLog) + }, shutdown.PriorityRemoteLog) } func sendLogMsg(level logger.Level, name string, msg string) { diff --git a/plugins/spa/drng_livefeed.go b/plugins/spa/drng_livefeed.go index 5f4b087e101fe931c3db099e5653568cf65dac0a..7788dcfb20064da81c22af649b31446f6e7f4d12 100644 --- a/plugins/spa/drng_livefeed.go +++ b/plugins/spa/drng_livefeed.go @@ -51,5 +51,5 @@ func runDrngLiveFeed() { newMsgRateLimiter.Stop() drngLiveFeedWorkerPool.Stop() log.Info("Stopping SPA[DRNGUpdater] ... done") - }, shutdown.ShutdownPrioritySPA) + }, shutdown.PrioritySPA) } diff --git a/plugins/spa/livefeed.go b/plugins/spa/livefeed.go index bf2ab1af07934adb9fdd15220098d256fa201ce4..551f09857cb7ed14cd6d671335442f5eef7e9a93 100644 --- a/plugins/spa/livefeed.go +++ b/plugins/spa/livefeed.go @@ -49,5 +49,5 @@ func runLiveFeed() { newMsgRateLimiter.Stop() liveFeedWorkerPool.Stop() log.Info("Stopping SPA[MsgUpdater] ... done") - }, shutdown.ShutdownPrioritySPA) + }, shutdown.PrioritySPA) } diff --git a/plugins/spa/plugin.go b/plugins/spa/plugin.go index e5b761496ea48432f7c3397ce4fb36ef78a13981..f1d3fce4eae500628f19067ba432960bbf5251d8 100644 --- a/plugins/spa/plugin.go +++ b/plugins/spa/plugin.go @@ -72,7 +72,7 @@ func run(plugin *node.Plugin) { metrics.Events.ReceivedTPSUpdated.Detach(notifyStatus) wsSendWorkerPool.Stop() log.Info("Stopping SPA[WSSend] ... done") - }, shutdown.ShutdownPrioritySPA) + }, shutdown.PrioritySPA) runLiveFeed() runDrngLiveFeed() diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index 2ebeb7beb3a660939e20b3fb46b83211cffa822f..1c69ea5d95c68d867902355d7910e5f536cc4708 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -46,5 +46,5 @@ func run(plugin *node.Plugin) { if err := Server.Shutdown(ctx); err != nil { log.Errorf("Couldn't stop server cleanly: %s", err.Error()) } - }, shutdown.ShutdownPriorityWebAPI) + }, shutdown.PriorityWebAPI) } diff --git a/plugins/webapi/spammer/plugin.go b/plugins/webapi/spammer/plugin.go index b83f0b6e390439b81c4c3c1f4c46edb6ca7ff5f6..318d89e6489ef5a3fb13ab544ce93d44c2796f1e 100644 --- a/plugins/webapi/spammer/plugin.go +++ b/plugins/webapi/spammer/plugin.go @@ -26,5 +26,5 @@ func run(*node.Plugin) { <-shutdownSignal transactionSpammer.Shutdown() - }, shutdown.ShutdownPrioritySpammer) + }, shutdown.PrioritySpammer) }