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
9bc31f6b
Commit
9bc31f6b
authored
Aug 28, 2023
by
Will Cory
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(indexer): Connect api metrics to cli
parent
b6cae656
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
1 deletion
+55
-1
cli.go
indexer/cmd/indexer/cli.go
+55
-1
No files found.
indexer/cmd/indexer/cli.go
View file @
9bc31f6b
...
...
@@ -66,6 +66,53 @@ func runApi(ctx *cli.Context) error {
return
api
.
Listen
(
ctx
.
Context
,
cfg
.
HTTPServer
.
Port
)
}
func
runApiMetrics
(
ctx
*
cli
.
Context
)
error
{
log
:=
log
.
NewLogger
(
log
.
ReadCLIConfig
(
ctx
))
.
New
(
"role"
,
"api"
)
cfg
,
err
:=
config
.
LoadConfig
(
log
,
ctx
.
String
(
ConfigFlag
.
Name
))
if
err
!=
nil
{
log
.
Error
(
"failed to load config"
,
"err"
,
err
)
return
err
}
db
,
err
:=
database
.
NewDB
(
cfg
.
DB
)
if
err
!=
nil
{
log
.
Error
(
"failed to connect to database"
,
"err"
,
err
)
return
err
}
api
:=
api
.
NewApi
(
log
,
db
.
BridgeTransfers
)
return
api
.
Listen
(
ctx
.
Context
,
cfg
.
Metrics
.
Port
)
}
func
runApiAndMetrics
(
ctx
*
cli
.
Context
)
error
{
log
:=
log
.
NewLogger
(
log
.
ReadCLIConfig
(
ctx
))
// Ensure both processes complete before returning.
var
wg
sync
.
WaitGroup
wg
.
Add
(
2
)
go
func
()
{
defer
wg
.
Done
()
err
:=
runApi
(
ctx
)
if
err
!=
nil
{
log
.
Error
(
"api process non-zero exit"
,
"err"
,
err
)
}
}()
go
func
()
{
defer
wg
.
Done
()
err
:=
runApiMetrics
(
ctx
)
if
err
!=
nil
{
log
.
Error
(
"indexer process non-zero exit"
,
"err"
,
err
)
}
}()
// We purposefully return no error since the indexer and api
// have no inter-dependencies. We simply rely on the logs to
// report a non-zero exit for either process.
wg
.
Wait
()
return
nil
}
func
runAll
(
ctx
*
cli
.
Context
)
error
{
log
:=
log
.
NewLogger
(
log
.
ReadCLIConfig
(
ctx
))
...
...
@@ -87,6 +134,13 @@ func runAll(ctx *cli.Context) error {
log
.
Error
(
"indexer process non-zero exit"
,
"err"
,
err
)
}
}()
go
func
()
{
defer
wg
.
Done
()
err
:=
runApiMetrics
(
ctx
)
if
err
!=
nil
{
log
.
Error
(
"indexer process non-zero exit"
,
"err"
,
err
)
}
}()
// We purposefully return no error since the indexer and api
// have no inter-dependencies. We simply rely on the logs to
...
...
@@ -107,7 +161,7 @@ func newCli(GitCommit string, GitDate string) *cli.App {
Name
:
"api"
,
Flags
:
flags
,
Description
:
"Runs the api service"
,
Action
:
runApi
,
Action
:
runApi
AndMetrics
,
},
{
Name
:
"index"
,
...
...
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