From a1a75dc2595c83160670921bcd1cc8a31d8d0d19 Mon Sep 17 00:00:00 2001 From: marcello33 Date: Fri, 10 Feb 2023 07:36:48 +0100 Subject: [PATCH] dev: add: stop services before stopping ec2 instances (#154) --- src/express/commands/cleanup.js | 2 +- src/express/commands/instances-stop.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/express/commands/cleanup.js b/src/express/commands/cleanup.js index f7326036..390f8726 100644 --- a/src/express/commands/cleanup.js +++ b/src/express/commands/cleanup.js @@ -11,7 +11,7 @@ export async function cleanup() { await deployBorContractsAndStateSync(doc) } -async function stopServices(doc) { +export async function stopServices(doc) { const borUsers = splitToArray(doc.devnetBorUsers.toString()) const nodeIps = [] const isHostMap = new Map() diff --git a/src/express/commands/instances-stop.js b/src/express/commands/instances-stop.js index 7402060c..75e9c544 100644 --- a/src/express/commands/instances-stop.js +++ b/src/express/commands/instances-stop.js @@ -2,6 +2,7 @@ import { loadDevnetConfig } from '../common/config-utils' import { timer } from '../common/time-utils' +import { stopServices } from './cleanup' const shell = require('shelljs') @@ -10,7 +11,10 @@ export async function stopInstances() { require('dotenv').config({ path: `${process.cwd()}/.env` }) const devnetType = process.env.TF_VAR_DOCKERIZED === 'yes' ? 'docker' : 'remote' + const doc = await loadDevnetConfig(devnetType) + await stopServices(doc) + const instances = doc.instancesIds.toString().replace(/,/g, ' ') shell.exec(`aws ec2 stop-instances --instance-ids ${instances}`)