( rmContainer = false )
| 259 | } |
| 260 | |
| 261 | export const stopDgraphContainer = async ( |
| 262 | rmContainer = false |
| 263 | ): Promise<void> => { |
| 264 | try { |
| 265 | let containerToRemove: undefined | string |
| 266 | const runningContainerId = await findExistingDGraphContainerId('running') |
| 267 | if (runningContainerId) { |
| 268 | logger.debug( |
| 269 | `Stopping ${rmContainer ? 'and deleting' : ''} ${runningContainerId}` |
| 270 | ) |
| 271 | await execCommand(`docker stop ${runningContainerId}`) |
| 272 | logger.debug(`${runningContainerId} stopped successfully`) |
| 273 | containerToRemove = runningContainerId |
| 274 | } else { |
| 275 | const exitedContainerId = await findExistingDGraphContainerId('exited') |
| 276 | if (exitedContainerId) { |
| 277 | containerToRemove = exitedContainerId |
| 278 | } |
| 279 | } |
| 280 | if (rmContainer && containerToRemove) { |
| 281 | await execCommand(`docker rm ${containerToRemove}`) |
| 282 | logger.debug(`${containerToRemove} removed successfully`) |
| 283 | } |
| 284 | } catch (error) { |
| 285 | logger.debug('Error while stopping dgraph container') |
| 286 | logger.debug(error) |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | export const initDgraphContainer = async (): Promise<void> => { |
| 291 | try { |
no test coverage detected