Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-currency-monit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
modules
duniter-currency-monit
Commits
8fe044ef
Commit
8fe044ef
authored
7 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[enh] add action indexing
parent
f7889e7c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
index.js
+40
-14
40 additions, 14 deletions
index.js
with
40 additions
and
14 deletions
index.js
+
40
−
14
View file @
8fe044ef
...
...
@@ -13,6 +13,10 @@ const main = require(__dirname + '/lib/main.js');
// Default Duniter node's database
//const DEFAULT_DUNITER_DATA_FOLDER = 'currency-monit-dev';
// host on which UI is available
const
DEFAULT_ACTION
=
'
start
'
;
// host on which UI is available
const
DEFAULT_HOST
=
'
localhost
'
;
...
...
@@ -42,8 +46,9 @@ module.exports = {
],
cli
:
[{
name
:
'
currency-monit [host] [port]
'
,
desc
:
'
Start duniter with module currency-monit
'
,
name
:
'
currency-monit [action=start] [host] [port]
'
,
desc
:
'
Action start : Start duniter with module currency-monit
\n
'
+
'
Action indexing : indexing blockchain
'
,
// Disables Duniter node's logs
logs
:
false
,
...
...
@@ -51,9 +56,12 @@ module.exports = {
onDatabaseExecute
:
(
server
,
conf
,
program
,
params
,
startServices
)
=>
co
(
function
*
()
{
// currency-monit parameters
const
SERVER_HOST
=
params
[
0
]
||
DEFAULT_HOST
;
const
SERVER_PORT
=
parseInt
(
params
[
1
])
||
DEFAULT_PORT
;
const
ACTION
=
params
[
0
]
||
DEFAULT_ACTION
;
const
SERVER_HOST
=
params
[
1
]
||
DEFAULT_HOST
;
const
SERVER_PORT
=
parseInt
(
params
[
2
])
||
DEFAULT_PORT
;
if
(
ACTION
==
"
start
"
)
{
// IMPORTANT: release Duniter services from "sleep" mode
yield
startServices
();
...
...
@@ -62,6 +70,24 @@ module.exports = {
// Wait forever, this is a permanent program
yield
new
Promise
(()
=>
null
);
}
else
if
(
ACTION
==
"
indexing
"
)
{
try
{
console
.
log
(
'
sync...
'
);
console
.
log
(
'
ok
'
);
}
catch
(
err
)
{
console
.
error
(
'
Error during blockchain indexing
'
,
err
);
}
// Close the DB connection properly
return
server
&&
server
.
disconnect
()
}
else
{
console
.
error
(
'
Error unknow action "%s" !
'
,
ACTION
);
// Close the DB connection properly
return
server
&&
server
.
disconnect
()
}
})
}]
},
...
...
This diff is collapsed.
Click to expand it.
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