Skip to content

Commit

Permalink
fix: Cleanup the logsink before closing the server (appium#15207)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Mar 22, 2021
1 parent 1037368 commit 5dbb9a4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
// transpile:main

import { init as logsinkInit } from './logsink';
import { init as logsinkInit, clear as logsinkClear } from './logsink';
import logger from './logger'; // logger needs to remain first of imports
import _ from 'lodash';
import { server as baseServer, routeConfiguringFunction as makeRouter } from 'appium-base-driver';
Expand Down Expand Up @@ -164,14 +164,18 @@ async function main (args = null) {
process.once(signal, async function onSignal () {
logger.info(`Received ${signal} - shutting down`);
try {
await appiumDriver.deleteAllSessions({
force: true,
reason: `The process has received ${signal} signal`,
});
await server.close();
try {
await appiumDriver.deleteAllSessions({
force: true,
reason: `The process has received ${signal} signal`,
});
logsinkClear();
} finally {
await server.close();
}
process.exit(0);
} catch (e) {
logger.warn(e);
logger.error(e.message);
process.exit(1);
}
});
Expand Down

0 comments on commit 5dbb9a4

Please sign in to comment.