Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Goshimmer_without_tipselection
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COLLET Ismael
Goshimmer_without_tipselection
Commits
99a43562
Unverified
Commit
99a43562
authored
4 years ago
by
Angelo Capossele
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add panic if backgroundWorker fails (#444)
*
Add panic if backgroundWorker fails *
Use log.Panicf instead of panic
parent
b8f0b053
No related branches found
No related tags found
No related merge requests found
Changes
23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
plugins/sync/plugin.go
+8
-4
8 additions, 4 deletions
plugins/sync/plugin.go
plugins/webapi/plugin.go
+1
-1
1 addition, 1 deletion
plugins/webapi/plugin.go
plugins/webapi/spammer/plugin.go
+8
-2
8 additions, 2 deletions
plugins/webapi/spammer/plugin.go
with
17 additions
and
7 deletions
plugins/sync/plugin.go
+
8
−
4
View file @
99a43562
...
@@ -130,7 +130,7 @@ func monitorForDesynchronization() {
...
@@ -130,7 +130,7 @@ func monitorForDesynchronization() {
}
}
})
})
daemon
.
BackgroundWorker
(
"Desync-Monitor"
,
func
(
shutdownSignal
<-
chan
struct
{})
{
if
err
:=
daemon
.
BackgroundWorker
(
"Desync-Monitor"
,
func
(
shutdownSignal
<-
chan
struct
{})
{
gossip
.
Manager
()
.
Events
()
.
NeighborRemoved
.
Attach
(
monitorPeerCountClosure
)
gossip
.
Manager
()
.
Events
()
.
NeighborRemoved
.
Attach
(
monitorPeerCountClosure
)
defer
gossip
.
Manager
()
.
Events
()
.
NeighborRemoved
.
Detach
(
monitorPeerCountClosure
)
defer
gossip
.
Manager
()
.
Events
()
.
NeighborRemoved
.
Detach
(
monitorPeerCountClosure
)
messagelayer
.
Tangle
.
Events
.
MessageAttached
.
Attach
(
monitorMessageInflowClosure
)
messagelayer
.
Tangle
.
Events
.
MessageAttached
.
Attach
(
monitorMessageInflowClosure
)
...
@@ -163,7 +163,9 @@ func monitorForDesynchronization() {
...
@@ -163,7 +163,9 @@ func monitorForDesynchronization() {
return
return
}
}
}
}
},
shutdown
.
PrioritySynchronization
)
},
shutdown
.
PrioritySynchronization
);
err
!=
nil
{
log
.
Panicf
(
"Failed to start as daemon: %s"
,
err
)
}
}
}
// starts a background worker and event handlers to check whether the node is synchronized by first collecting
// starts a background worker and event handlers to check whether the node is synchronized by first collecting
...
@@ -200,7 +202,7 @@ func monitorForSynchronization() {
...
@@ -200,7 +202,7 @@ func monitorForSynchronization() {
synced
<-
types
.
Empty
{}
synced
<-
types
.
Empty
{}
})
})
daemon
.
BackgroundWorker
(
"Sync-Monitor"
,
func
(
shutdownSignal
<-
chan
struct
{})
{
if
err
:=
daemon
.
BackgroundWorker
(
"Sync-Monitor"
,
func
(
shutdownSignal
<-
chan
struct
{})
{
messagelayer
.
Tangle
.
Events
.
MessageAttached
.
Attach
(
initAnchorPointClosure
)
messagelayer
.
Tangle
.
Events
.
MessageAttached
.
Attach
(
initAnchorPointClosure
)
defer
messagelayer
.
Tangle
.
Events
.
MessageAttached
.
Detach
(
initAnchorPointClosure
)
defer
messagelayer
.
Tangle
.
Events
.
MessageAttached
.
Detach
(
initAnchorPointClosure
)
messagelayer
.
Tangle
.
Events
.
MessageSolid
.
Attach
(
checkAnchorPointSolidityClosure
)
messagelayer
.
Tangle
.
Events
.
MessageSolid
.
Attach
(
checkAnchorPointSolidityClosure
)
...
@@ -228,7 +230,9 @@ func monitorForSynchronization() {
...
@@ -228,7 +230,9 @@ func monitorForSynchronization() {
return
return
}
}
}
}
},
shutdown
.
PrioritySynchronization
)
},
shutdown
.
PrioritySynchronization
);
err
!=
nil
{
log
.
Panicf
(
"Failed to start as daemon: %s"
,
err
)
}
}
}
// fills up the anchor points with newly attached messages which then are used to determine whether we are synchronized.
// fills up the anchor points with newly attached messages which then are used to determine whether we are synchronized.
...
...
This diff is collapsed.
Click to expand it.
plugins/webapi/plugin.go
+
1
−
1
View file @
99a43562
...
@@ -37,7 +37,7 @@ func configure(*node.Plugin) {
...
@@ -37,7 +37,7 @@ func configure(*node.Plugin) {
func
run
(
*
node
.
Plugin
)
{
func
run
(
*
node
.
Plugin
)
{
log
.
Infof
(
"Starting %s ..."
,
PluginName
)
log
.
Infof
(
"Starting %s ..."
,
PluginName
)
if
err
:=
daemon
.
BackgroundWorker
(
"WebAPI Server"
,
worker
,
shutdown
.
PriorityWebAPI
);
err
!=
nil
{
if
err
:=
daemon
.
BackgroundWorker
(
"WebAPI Server"
,
worker
,
shutdown
.
PriorityWebAPI
);
err
!=
nil
{
log
.
Errorf
(
"Error
start
ing
as daemon: %s"
,
err
)
log
.
Panicf
(
"Failed to
start as daemon: %s"
,
err
)
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
plugins/webapi/spammer/plugin.go
+
8
−
2
View file @
99a43562
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"github.com/iotaledger/goshimmer/plugins/issuer"
"github.com/iotaledger/goshimmer/plugins/issuer"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node"
"github.com/iotaledger/hive.go/node"
)
)
...
@@ -17,15 +18,20 @@ const PluginName = "Spammer"
...
@@ -17,15 +18,20 @@ const PluginName = "Spammer"
// Plugin is the plugin instance of the spammer plugin.
// Plugin is the plugin instance of the spammer plugin.
var
Plugin
=
node
.
NewPlugin
(
PluginName
,
node
.
Disabled
,
configure
,
run
)
var
Plugin
=
node
.
NewPlugin
(
PluginName
,
node
.
Disabled
,
configure
,
run
)
var
log
*
logger
.
Logger
func
configure
(
plugin
*
node
.
Plugin
)
{
func
configure
(
plugin
*
node
.
Plugin
)
{
log
=
logger
.
NewLogger
(
PluginName
)
messageSpammer
=
spammer
.
New
(
issuer
.
IssuePayload
)
messageSpammer
=
spammer
.
New
(
issuer
.
IssuePayload
)
webapi
.
Server
.
GET
(
"spammer"
,
handleRequest
)
webapi
.
Server
.
GET
(
"spammer"
,
handleRequest
)
}
}
func
run
(
*
node
.
Plugin
)
{
func
run
(
*
node
.
Plugin
)
{
_
=
daemon
.
BackgroundWorker
(
"Tangle"
,
func
(
shutdownSignal
<-
chan
struct
{})
{
if
err
:
=
daemon
.
BackgroundWorker
(
"Tangle"
,
func
(
shutdownSignal
<-
chan
struct
{})
{
<-
shutdownSignal
<-
shutdownSignal
messageSpammer
.
Shutdown
()
messageSpammer
.
Shutdown
()
},
shutdown
.
PrioritySpammer
)
},
shutdown
.
PrioritySpammer
);
err
!=
nil
{
log
.
Panicf
(
"Failed to start as daemon: %s"
,
err
)
}
}
}
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment