@@ -287,6 +287,16 @@ export class HyperionMaster {
287287 this . total_range = this . head - msg . block_num ;
288288 }
289289 } ,
290+ 'kill_worker' : ( msg : any ) => {
291+ for ( let workersKey in cluster . workers ) {
292+ const w = cluster . workers [ workersKey ] ;
293+ if ( w . id === parseInt ( msg . id ) ) {
294+ const idx = this . workerMap . findIndex ( value => value . worker_id === w . id ) ;
295+ this . workerMap . splice ( idx , 1 ) ;
296+ w . kill ( ) ;
297+ }
298+ }
299+ } ,
290300 'completed' : ( msg : any ) => {
291301 if ( msg . id === this . doctorId . toString ( ) ) {
292302 hLog ( 'repair worker completed' , msg ) ;
@@ -645,7 +655,7 @@ export class HyperionMaster {
645655 index : new_index
646656 } ) ;
647657 } catch ( e ) {
648- console . log ( e ) ;
658+ hLog ( e ) ;
649659 process . exit ( 1 ) ;
650660 }
651661
@@ -657,7 +667,7 @@ export class HyperionMaster {
657667 name : `${ queue_prefix } -${ index . type } `
658668 } ) ;
659669 } catch ( e ) {
660- console . log ( e ) ;
670+ hLog ( e ) ;
661671 process . exit ( 1 ) ;
662672 }
663673
@@ -1500,7 +1510,11 @@ export class HyperionMaster {
15001510 hLog ( log_msg . join ( ' | ' ) ) ;
15011511 }
15021512
1503- if ( this . indexedObjects === 0 && this . deserializedActions === 0 && this . consumedBlocks === 0 && ! this . mode_transition ) {
1513+ if ( this . liveConsumedBlocks > 0 && this . consumedBlocks === 0 && this . conf . indexer . abi_scan_mode ) {
1514+ hLog ( 'Warning: Live reading on ABI SCAN mode' )
1515+ }
1516+
1517+ if ( this . liveConsumedBlocks + this . indexedObjects + this . deserializedActions + this . consumedBlocks === 0 && ! this . mode_transition ) {
15041518
15051519 // Report completed range (parallel reading)
15061520 if ( this . total_blocks === this . total_range && ! this . range_completed ) {
@@ -1549,6 +1563,13 @@ export class HyperionMaster {
15491563 }
15501564 } else {
15511565 if ( ! this . shutdownStarted ) {
1566+ const readers = this . workerMap . filter ( value => {
1567+ return value . worker_role === 'reader' || value . worker_role === 'continuous_reader' ;
1568+ } ) ;
1569+ if ( readers . length === 0 ) {
1570+ hLog ( `No more active workers, stopping now...` ) ;
1571+ process . exit ( ) ;
1572+ }
15521573 const idleMsg = 'No blocks are being processed, please check your state-history node!' ;
15531574 if ( this . idle_count === 2 ) {
15541575 this . emitAlert ( 'warning' , idleMsg ) ;
@@ -1715,7 +1736,16 @@ export class HyperionMaster {
17151736 this . ioRedisClient = new IORedis ( this . manager . conn . redis ) ;
17161737
17171738 // Remove first indexed block from cache (v2/health)
1718- await this . ioRedisClient . del ( `${ this . manager . chain } ::fib` )
1739+ await this . ioRedisClient . del ( `${ this . manager . chain } ::fib` ) ;
1740+
1741+ // check nodeos
1742+ try {
1743+ const info = await this . rpc . get_info ( ) ;
1744+ hLog ( `Nodeos version: ${ info . server_version_string } ` ) ;
1745+ } catch ( e ) {
1746+ hLog ( `Chain API Error: ${ e . message } ` ) ;
1747+ process . exit ( ) ;
1748+ }
17191749
17201750 // Elasticsearch
17211751 this . client = this . manager . elasticsearchClient ;
@@ -1822,9 +1852,9 @@ export class HyperionMaster {
18221852 // handle worker disconnection events
18231853 cluster . on ( 'disconnect' , ( worker ) => {
18241854 if ( ! this . mode_transition && ! this . shutdownStarted ) {
1825- hLog ( `The worker #${ worker . id } has disconnected, attempting to re-launch in 5 seconds...` ) ;
18261855 const workerReference = this . workerMap . find ( value => value . worker_id === worker . id ) ;
18271856 if ( workerReference ) {
1857+ hLog ( `The worker #${ worker . id } has disconnected, attempting to re-launch in 5 seconds...` ) ;
18281858 workerReference . wref = null ;
18291859 workerReference . failures ++ ;
18301860 hLog ( `New worker defined: ${ workerReference . worker_role } for ${ workerReference . worker_queue } ` ) ;
@@ -1840,7 +1870,7 @@ export class HyperionMaster {
18401870 } , 1000 ) ;
18411871 } , 5000 ) ;
18421872 } else {
1843- console . log ( `Worker #${ worker . id } not found in map! `) ;
1873+ hLog ( `The worker #${ worker . id } has disconnected `) ;
18441874 }
18451875 }
18461876 } ) ;
@@ -2216,9 +2246,7 @@ export class HyperionMaster {
22162246 await this . setupIndexers ( ) ;
22172247 await this . setupStreaming ( ) ;
22182248 await this . setupDSPool ( ) ;
2219- this . addWorker ( {
2220- worker_role : "delta_updater"
2221- } ) ;
2249+ this . addWorker ( { worker_role : "delta_updater" } ) ;
22222250 }
22232251
22242252 private async findRange ( ) {
@@ -2244,8 +2272,7 @@ export class HyperionMaster {
22442272 try {
22452273 this . chain_data = await this . rpc . get_info ( ) ;
22462274 } catch ( e ) {
2247- console . log ( e . message ) ;
2248- console . error ( 'failed to connect to chain api' ) ;
2275+ hLog ( 'Failed to connect to chain api: ' + e . message ) ;
22492276 process . exit ( 1 ) ;
22502277 }
22512278 this . head = this . chain_data . head_block_num ;
0 commit comments