diff --git a/packages/shutdown/order.go b/packages/shutdown/order.go new file mode 100644 index 0000000000000000000000000000000000000000..b16bc91e04b45b2e9744555ae229ab359d9cb18e --- /dev/null +++ b/packages/shutdown/order.go @@ -0,0 +1,18 @@ +package shutdown + +const ( + ShutdownPriorityTangle = iota + ShutdownPrioritySolidifier + ShutdownPriorityBundleProcessor + ShutdownPriorityAnalysis + ShutdownPriorityMetrics + ShutdownPriorityWebAPI + ShutdownPriorityGossip + ShutdownPriorityZMQ + ShutdownPriorityAutopeering + ShutdownPriorityGraph + ShutdownPriorityUI + ShutdownPriorityDashboard + ShutdownPriorityTangleSpammer + ShutdownPriorityStatusScreen +) diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index a2cae4aefa4b3ae824008dc44cc8332bc13c9b86..dcfb1da1ed9d5dbea4dd3ad676054a7e30940f26 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -4,6 +4,7 @@ import ( "sync" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/packages/gossip" @@ -79,7 +80,7 @@ func Start(tps uint) { } } } - }) + }, shutdown.ShutdownPriorityTangleSpammer) } func Stop() { diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 506982347c0b066946b2b0360c6cf034b2c6a7a4..ccec3955a929c7adf3bb9a14ef9204d2dc0bacc0 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -8,6 +8,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" @@ -50,7 +51,7 @@ func Run(plugin *node.Plugin) { } } } - }) + }, shutdown.ShutdownPriorityAnalysis) } func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers { diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index 35973f84a6fb701a4c1001c234750c6b004f41eb..a46f4c2fe96001b05d8ccb24d8172bd110edd566 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" @@ -45,7 +46,7 @@ func Run(plugin *node.Plugin) { go server.Listen(parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) <-shutdownSignal Shutdown() - }) + }, shutdown.ShutdownPriorityAnalysis) } func Shutdown() { diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index 0299e173ed36d9e4ec983781e96a1a9a6e8bb3ac..fa3f2b501bdb34eefa24106440042fa63fc44e10 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -4,6 +4,7 @@ import ( "net/http" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/node" "golang.org/x/net/context" @@ -30,5 +31,5 @@ func Run(plugin *node.Plugin) { ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) defer cancel() httpServer.Shutdown(ctx) - }) + }, shutdown.ShutdownPriorityAnalysis) } diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 04321f98b21b2383b5b2c57d55c25ca9db1326dd..c6e9ec88f523ace8ac8852eabd55f4862b17cb12 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -5,6 +5,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/gossip" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" @@ -23,7 +24,7 @@ func configure(*node.Plugin) { } func run(*node.Plugin) { - if err := daemon.BackgroundWorker(name, start); err != nil { + if err := daemon.BackgroundWorker(name, start, shutdown.ShutdownPriorityAutopeering); err != nil { log.Errorf("Failed to start as daemon: %s", err) } } diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index ad4ecb52eb13fcb1ea3b03a6947a2e0e9f3fc52d..822a2952df50aa39ce8c224bea3839918ec9071f 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -3,6 +3,7 @@ package bundleprocessor import ( "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -37,7 +38,7 @@ func run(*node.Plugin) { log.Info("Stopping Bundle Processor ...") workerPool.StopAndWait() log.Info("Stopping Bundle Processor ... done") - }) + }, shutdown.ShutdownPriorityBundleProcessor) log.Info("Starting Value Bundle Processor ...") @@ -48,5 +49,5 @@ func run(*node.Plugin) { log.Info("Stopping Value Bundle Processor ...") valueBundleProcessorWorkerPool.StopAndWait() log.Info("Stopping Value Bundle Processor ... done") - }) + }, shutdown.ShutdownPriorityBundleProcessor) } diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index 4321e0b5c5f452fbb6498d400eb925f14107646e..5fa26f69825702d1c9f340499261e8eb3512465c 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -4,6 +4,7 @@ import ( "net/http" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -48,5 +49,5 @@ func run(plugin *node.Plugin) { ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) defer cancel() _ = server.Shutdown(ctx) - }) + }, shutdown.ShutdownPriorityDashboard) } diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 0a4f61e4b80886b1051cf7eed613be6d31b7f8eb..3829565b380413c256198b78f37f17a17f6afb73 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -5,6 +5,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -24,7 +25,7 @@ func configure(*node.Plugin) { } func run(*node.Plugin) { - if err := daemon.BackgroundWorker(name, start); err != nil { + if err := daemon.BackgroundWorker(name, start, shutdown.ShutdownPriorityGossip); err != nil { log.Errorf("Failed to start as daemon: %s", err) } } diff --git a/plugins/graph/plugin.go b/plugins/graph/plugin.go index 39e3df4703b56c31afdc13b591cd034cb72877ef..f6dcc3eea3cd10d4db3f9483117bea6208ba8706 100644 --- a/plugins/graph/plugin.go +++ b/plugins/graph/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "golang.org/x/net/context" @@ -105,7 +106,7 @@ func run(plugin *node.Plugin) { tangle.Events.TransactionStored.Detach(notifyNewTx) newTxWorkerPool.Stop() log.Info("Stopping Graph[NewTxWorker] ... done") - }) + }, shutdown.ShutdownPriorityGraph) daemon.BackgroundWorker("Graph Webserver", func(shutdownSignal <-chan struct{}) { go socketioServer.Serve() @@ -128,5 +129,5 @@ func run(plugin *node.Plugin) { _ = server.Shutdown(ctx) log.Info("Stopping Graph ... done") - }) + }, shutdown.ShutdownPriorityGraph) } diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index 4774c72d3c540f57f900660502a21d33686cae84..3624874e7043d791ae61c8fb9129d35d59dc772c 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -4,6 +4,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/gossip" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" @@ -21,5 +22,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) } diff --git a/plugins/statusscreen-tps/plugin.go b/plugins/statusscreen-tps/plugin.go index c4909e45e6df63501c3deeffced361a5e36c9621..dbe6b89276081d1cd08a669eb014d16488f97834 100644 --- a/plugins/statusscreen-tps/plugin.go +++ b/plugins/statusscreen-tps/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/statusscreen" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" @@ -51,5 +52,5 @@ var PLUGIN = node.NewPlugin("Statusscreen TPS", node.Enabled, func(plugin *node. atomic.StoreUint64(&solidTpsCounter, 0) } } - }) + }, shutdown.ShutdownPriorityStatusScreen) }) diff --git a/plugins/statusscreen/plugin.go b/plugins/statusscreen/plugin.go index f79ca05ebf4b15a65be6fb7ca361cfd692092e3f..e117234f75f1f2c0c1e5f63171cd49f73755b3a9 100644 --- a/plugins/statusscreen/plugin.go +++ b/plugins/statusscreen/plugin.go @@ -3,6 +3,7 @@ package statusscreen import ( "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" @@ -57,7 +58,7 @@ func run(*node.Plugin) { return } } - }); err != nil { + }, shutdown.ShutdownPriorityStatusScreen); err != nil { log.Errorf("Failed to start as daemon: %s", err) return } @@ -72,7 +73,7 @@ func run(*node.Plugin) { if err := app.SetRoot(frame, true).SetFocus(frame).Run(); err != nil { log.Errorf("Error running application: %s", err) } - }); err != nil { + }, shutdown.ShutdownPriorityStatusScreen); err != nil { log.Errorf("Failed to start as daemon: %s", err) close(stopped) } diff --git a/plugins/tangle/approvers.go b/plugins/tangle/approvers.go index 38d44aa9081d62e6f47710cf31c8c2c10110d042..166b1a7ed0e8b969017c84855ce98ade6db8d419 100644 --- a/plugins/tangle/approvers.go +++ b/plugins/tangle/approvers.go @@ -2,9 +2,9 @@ package tangle import ( "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/approvers" + "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -50,20 +50,26 @@ func StoreApprovers(approvers *approvers.Approvers) { // region lru cache //////////////////////////////////////////////////////////////////////////////////////////////////// -var approversCache = datastructure.NewLRUCache(APPROVERS_CACHE_SIZE, &datastructure.LRUCacheOptions{ - EvictionCallback: onEvictApprovers, +var approversCache = lru_cache.NewLRUCache(APPROVERS_CACHE_SIZE, &lru_cache.LRUCacheOptions{ + EvictionCallback: onEvictApprovers, + EvictionBatchSize: 100, }) -func onEvictApprovers(_ interface{}, value interface{}) { - if evictedApprovers := value.(*approvers.Approvers); evictedApprovers.GetModified() { - go func(evictedApprovers *approvers.Approvers) { - if err := storeApproversInDatabase(evictedApprovers); err != nil { +func onEvictApprovers(_ interface{}, values interface{}) { + // TODO: replace with apply + for _, obj := range values.([]interface{}) { + if approvers := obj.(*approvers.Approvers); approvers.GetModified() { + if err := storeApproversInDatabase(approvers); err != nil { panic(err) } - }(evictedApprovers) + } } } +func FlushApproversCache() { + approversCache.DeleteAll() +} + const ( APPROVERS_CACHE_SIZE = 50000 ) diff --git a/plugins/tangle/bundle.go b/plugins/tangle/bundle.go index fa607ba127fd374028bff25259ef55c92c9d96a5..ca7208a932492d1cbfaa43bff98c4596353d5edc 100644 --- a/plugins/tangle/bundle.go +++ b/plugins/tangle/bundle.go @@ -2,9 +2,9 @@ package tangle import ( "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" + "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -54,20 +54,26 @@ func StoreBundle(bundle *bundle.Bundle) { // region lru cache //////////////////////////////////////////////////////////////////////////////////////////////////// -var bundleCache = datastructure.NewLRUCache(BUNDLE_CACHE_SIZE, &datastructure.LRUCacheOptions{ - EvictionCallback: onEvictBundle, +var bundleCache = lru_cache.NewLRUCache(BUNDLE_CACHE_SIZE, &lru_cache.LRUCacheOptions{ + EvictionCallback: onEvictBundles, + EvictionBatchSize: 100, }) -func onEvictBundle(_ interface{}, value interface{}) { - if evictedBundle := value.(*bundle.Bundle); evictedBundle.GetModified() { - go func(evictedBundle *bundle.Bundle) { - if err := storeBundleInDatabase(evictedBundle); err != nil { +func onEvictBundles(_ interface{}, values interface{}) { + // TODO: replace with apply + for _, obj := range values.([]interface{}) { + if bndl := obj.(*bundle.Bundle); bndl.GetModified() { + if err := storeBundleInDatabase(bndl); err != nil { panic(err) } - }(evictedBundle) + } } } +func FlushBundleCache() { + bundleCache.DeleteAll() +} + const ( BUNDLE_CACHE_SIZE = 500 ) diff --git a/plugins/tangle/plugin.go b/plugins/tangle/plugin.go index 483d57b7b084e6c5fe8b75ee0589f00776f05d71..252c2b987da1db3774e0def97e65582f879a8c6c 100644 --- a/plugins/tangle/plugin.go +++ b/plugins/tangle/plugin.go @@ -1,6 +1,9 @@ package tangle import ( + "github.com/iotaledger/goshimmer/packages/database" + "github.com/iotaledger/goshimmer/packages/shutdown" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" @@ -20,6 +23,22 @@ func configure(*node.Plugin) { configureBundleDatabase() configureTransactionHashesForAddressDatabase() configureSolidifier() + + daemon.BackgroundWorker("Cache Flush", func(shutdownSignal <-chan struct{}) { + <-shutdownSignal + + log.Info("Flushing caches to database...") + FlushTransactionCache() + FlushTransactionMetadata() + FlushApproversCache() + FlushBundleCache() + log.Info("Flushing caches to database... done") + + log.Info("Syncing database to disk...") + database.GetBadgerInstance().Close() + log.Info("Syncing database to disk... done") + }, shutdown.ShutdownPriorityTangle) + } func run(*node.Plugin) { diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 7e6e8c4f84e269fc0ae8eb2bd770e781fb3b9805..2ab00159f6fe8da8aab1b502d69013b9fb14d72c 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -10,6 +10,7 @@ import ( "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/packages/workerpool" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -62,7 +63,7 @@ func runSolidifier() { log.Info("Stopping Solidifier ...") workerPool.StopAndWait() log.Info("Stopping Solidifier ... done") - }) + }, shutdown.ShutdownPrioritySolidifier) } // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/tangle/transaction.go b/plugins/tangle/transaction.go index 31edfc4f8c478aa4dd927e226c719ad3dfc53699..0de47154fd96b64915ef689e14e23e660b9a0fbe 100644 --- a/plugins/tangle/transaction.go +++ b/plugins/tangle/transaction.go @@ -2,9 +2,9 @@ package tangle import ( "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -51,20 +51,26 @@ func StoreTransaction(transaction *value_transaction.ValueTransaction) { // region lru cache //////////////////////////////////////////////////////////////////////////////////////////////////// -var transactionCache = datastructure.NewLRUCache(TRANSACTION_CACHE_SIZE, &datastructure.LRUCacheOptions{ - EvictionCallback: onEvictTransaction, +var transactionCache = lru_cache.NewLRUCache(TRANSACTION_CACHE_SIZE, &lru_cache.LRUCacheOptions{ + EvictionCallback: onEvictTransactions, + EvictionBatchSize: 200, }) -func onEvictTransaction(_ interface{}, value interface{}) { - if evictedTransaction := value.(*value_transaction.ValueTransaction); evictedTransaction.GetModified() { - go func(evictedTransaction *value_transaction.ValueTransaction) { - if err := storeTransactionInDatabase(evictedTransaction); err != nil { +func onEvictTransactions(_ interface{}, values interface{}) { + // TODO: replace with apply + for _, obj := range values.([]interface{}) { + if tx := obj.(*value_transaction.ValueTransaction); tx.GetModified() { + if err := storeTransactionInDatabase(tx); err != nil { panic(err) } - }(evictedTransaction) + } } } +func FlushTransactionCache() { + transactionCache.DeleteAll() +} + const ( TRANSACTION_CACHE_SIZE = 500 ) diff --git a/plugins/tangle/transaction_metadata.go b/plugins/tangle/transaction_metadata.go index 6713ecc8b006496044a3c85e85d2e4a6a5124729..0ea3c9828c7dda77375dcc319a4fc317fc571030 100644 --- a/plugins/tangle/transaction_metadata.go +++ b/plugins/tangle/transaction_metadata.go @@ -2,9 +2,9 @@ package tangle import ( "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" + "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -51,20 +51,26 @@ func StoreTransactionMetadata(transactionMetadata *transactionmetadata.Transacti // region lru cache //////////////////////////////////////////////////////////////////////////////////////////////////// -var transactionMetadataCache = datastructure.NewLRUCache(TRANSACTION_METADATA_CACHE_SIZE, &datastructure.LRUCacheOptions{ - EvictionCallback: onEvictTransactionMetadata, +var transactionMetadataCache = lru_cache.NewLRUCache(TRANSACTION_METADATA_CACHE_SIZE, &lru_cache.LRUCacheOptions{ + EvictionCallback: onEvictTransactionMetadatas, + EvictionBatchSize: 200, }) -func onEvictTransactionMetadata(_ interface{}, value interface{}) { - if evictedTransactionMetadata := value.(*transactionmetadata.TransactionMetadata); evictedTransactionMetadata.GetModified() { - go func(evictedTransactionMetadata *transactionmetadata.TransactionMetadata) { - if err := storeTransactionMetadataInDatabase(evictedTransactionMetadata); err != nil { +func onEvictTransactionMetadatas(_ interface{}, values interface{}) { + // TODO: replace with apply + for _, obj := range values.([]interface{}) { + if txMetadata := obj.(*transactionmetadata.TransactionMetadata); txMetadata.GetModified() { + if err := storeTransactionMetadataInDatabase(txMetadata); err != nil { panic(err) } - }(evictedTransactionMetadata) + } } } +func FlushTransactionMetadata() { + transactionCache.DeleteAll() +} + const ( TRANSACTION_METADATA_CACHE_SIZE = 500 ) diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 9d9b8b1cb50a915a1f4ffd838d5a698df7fcf766..3c41121078aa380e5a55b00388b96ea137518768 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -8,6 +8,7 @@ import ( "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/daemon" @@ -86,7 +87,7 @@ func run(plugin *node.Plugin) { wsMutex.Unlock() } } - }) + }, shutdown.ShutdownPriorityUI) } // PLUGIN plugs the UI into the main program diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index 6cd2e037b3f6ad471df85dbe1b40dce0c50d17dd..c7bd41f334d257aadd74973b31d22e899208ed6f 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" @@ -43,5 +44,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) } diff --git a/plugins/webauth/webauth.go b/plugins/webauth/webauth.go index 2b9048781ff915a8269f8a081a735f3270de3769..aa7ba5b340e3cb0c232b97ccf0cf970fd11ab965 100644 --- a/plugins/webauth/webauth.go +++ b/plugins/webauth/webauth.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/node" @@ -66,7 +67,7 @@ func run(plugin *node.Plugin) { "token": t, }) }) - }) + }, shutdown.ShutdownPriorityWebAPI) } // PLUGIN plugs the UI into the main program diff --git a/plugins/zeromq/plugin.go b/plugins/zeromq/plugin.go index 11ddb33c23927cc873e6a8ff2d83e0288cd194d5..0bf553b3314a0d86b16e199a8a3af911bf14ecda 100644 --- a/plugins/zeromq/plugin.go +++ b/plugins/zeromq/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -53,7 +54,7 @@ func run(plugin *node.Plugin) { } else { log.Info("Stopping ZeroMQ Publisher ... done") } - }) + }, shutdown.ShutdownPriorityZMQ) } // Start the zmq publisher.