Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
6fe9bbe8
Commit
6fe9bbe8
authored
Aug 07, 2023
by
Hamdi Allam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
catch panics and log config failures
parent
0f52d3d4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
11 deletions
+25
-11
cli.go
indexer/cli/cli.go
+13
-9
indexer.go
indexer/indexer.go
+12
-2
No files found.
indexer/cli/cli.go
View file @
6fe9bbe8
...
...
@@ -23,15 +23,16 @@ type Cli struct {
}
func
runIndexer
(
ctx
*
cli
.
Context
)
error
{
logger
:=
log
.
NewLogger
(
log
.
ReadCLIConfig
(
ctx
))
configPath
:=
ctx
.
String
(
ConfigFlag
.
Name
)
cfg
,
err
:=
config
.
LoadConfig
(
configPath
)
if
err
!=
nil
{
logger
.
Error
(
"failed to load config"
,
"err"
,
err
)
return
err
}
// setup logger
cfg
.
Logger
=
log
.
NewLogger
(
log
.
ReadCLIConfig
(
ctx
))
cfg
.
Logger
=
logger
indexer
,
err
:=
indexer
.
NewIndexer
(
cfg
)
if
err
!=
nil
{
return
err
...
...
@@ -47,17 +48,20 @@ func runIndexer(ctx *cli.Context) error {
}
func
runApi
(
ctx
*
cli
.
Context
)
error
{
configPath
:=
ctx
.
String
(
ConfigFlag
.
Name
)
conf
,
err
:=
config
.
LoadConfig
(
configPath
)
fmt
.
Println
(
conf
)
logger
:=
log
.
NewLogger
(
log
.
ReadCLIConfig
(
ctx
))
configPath
:=
ctx
.
String
(
ConfigFlag
.
Name
)
cfg
,
err
:=
config
.
LoadConfig
(
configPath
)
if
err
!=
nil
{
panic
(
err
)
logger
.
Error
(
"failed to load config"
,
"err"
,
err
)
return
err
}
cfg
.
Logger
=
logger
fmt
.
Println
(
cfg
)
// finish me
return
nil
return
err
}
var
(
...
...
indexer/indexer.go
View file @
6fe9bbe8
...
...
@@ -2,6 +2,7 @@ package indexer
import
(
"context"
"errors"
"fmt"
"sync"
...
...
@@ -72,13 +73,20 @@ func NewIndexer(cfg config.Config) (*Indexer, error) {
// Start starts the indexing service on L1 and L2 chains
func
(
i
*
Indexer
)
Run
(
ctx
context
.
Context
)
error
{
var
wg
sync
.
WaitGroup
errCh
:=
make
(
chan
error
)
errCh
:=
make
(
chan
error
,
1
)
// If either processor errors out, we stop
processorCtx
,
cancel
:=
context
.
WithCancel
(
ctx
)
run
:=
func
(
start
func
(
ctx
context
.
Context
)
error
)
{
wg
.
Add
(
1
)
defer
wg
.
Done
()
defer
func
()
{
if
err
:=
recover
();
err
!=
nil
{
i
.
log
.
Error
(
"halting indexer on panic"
,
"err"
,
err
)
errCh
<-
fmt
.
Errorf
(
"panic: %v"
,
err
)
}
wg
.
Done
()
}()
err
:=
start
(
processorCtx
)
if
err
!=
nil
{
...
...
@@ -86,6 +94,8 @@ func (i *Indexer) Run(ctx context.Context) error {
cancel
()
errCh
<-
err
}
else
{
errCh
<-
errors
.
New
(
"processor stopped"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment