@@ -36,6 +36,8 @@ import * as ServiceQueue from './ServiceQueue'
36
36
import Shardus from '../shardus'
37
37
import path from "path" ;
38
38
import fs from "fs/promises" ;
39
+ import { localConfig } from "@src/config/localConfig" ;
40
+ import { sleep } from "../utils" ;
39
41
40
42
/** STATE */
41
43
@@ -293,8 +295,8 @@ export function startupV2(shardus: Shardus): Promise<boolean> {
293
295
294
296
// check if file exists first
295
297
let fileExists = false
296
- const filePath = path . join ( Context . config . p2p . verticalScalingMode . path , '.sync-request' )
297
- if ( Context . config . p2p . verticalScalingMode . enabled ) {
298
+ const filePath = path . join ( localConfig . verticalScalingMode_path , '.sync-request' )
299
+ if ( localConfig . verticalScalingMode_enabled ) {
298
300
info ( 'verticalScalingMode: enabled' )
299
301
// eslint-disable-next-line security/detect-non-literal-fs-filename
300
302
fileExists = await fs . stat ( filePath )
@@ -307,7 +309,11 @@ export function startupV2(shardus: Shardus): Promise<boolean> {
307
309
try {
308
310
// eslint-disable-next-line security/detect-non-literal-fs-filename
309
311
await fs . writeFile ( filePath , resp . id )
310
- process . exit ( 1 ) // exiting with status 1 causes our modified PM2 to not restart the process
312
+ if ( localConfig . verticalScalingMode_shutdown_mode === 'shutdown' ) {
313
+ process . exit ( 1 ) // exiting with status 1 causes our modified PM2 to not restart the process
314
+ } else {
315
+ await sleep ( 10 * 10000 ) // sleep for 10 seconds
316
+ }
311
317
} catch ( err ) {
312
318
console . error ( 'The file could not be saved:' , err )
313
319
}
@@ -317,7 +323,7 @@ export function startupV2(shardus: Shardus): Promise<boolean> {
317
323
//detect if we are a zombie node (bounce and network think we are still active)
318
324
//if we never even tried to join yet but the network thinks we are active
319
325
//then we are a zombie node
320
- const skipSyncingState = Context . config . p2p . verticalScalingMode . enabled && fileExists
326
+ const skipSyncingState = localConfig . verticalScalingMode_enabled && fileExists
321
327
info ( `startupV2: skipSyncingState ${ skipSyncingState } ` )
322
328
if ( firstTimeJoiningLoop === true && ! skipSyncingState ) {
323
329
isFailed = true
@@ -344,7 +350,7 @@ export function startupV2(shardus: Shardus): Promise<boolean> {
344
350
}
345
351
346
352
// cleanup the file for the next run
347
- if ( Context . config . p2p . verticalScalingMode . enabled && fileExists ) {
353
+ if ( localConfig . verticalScalingMode_enabled && fileExists ) {
348
354
try {
349
355
// eslint-disable-next-line security/detect-non-literal-fs-filename
350
356
await fs . unlink ( filePath )
0 commit comments