2022-12-21 14:08:44 +00:00
|
|
|
import restoreImpl from "./restoreImpl";
|
|
|
|
import { StateProvider } from "./stateProvider";
|
2019-10-30 18:48:49 +00:00
|
|
|
|
2023-08-08 15:15:33 +00:00
|
|
|
async function run(earlyExit?: boolean | undefined): Promise<void> {
|
2023-08-07 18:32:07 +00:00
|
|
|
try {
|
|
|
|
await restoreImpl(new StateProvider());
|
|
|
|
} catch (err) {
|
|
|
|
console.error(err);
|
2023-08-08 15:15:33 +00:00
|
|
|
if (earlyExit) {
|
|
|
|
process.exit(1);
|
|
|
|
}
|
2023-08-07 18:32:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// node will stay alive if any promises are not resolved,
|
|
|
|
// which is a possibility if HTTP requests are dangling
|
|
|
|
// due to retries or timeouts. We know that if we got here
|
|
|
|
// that all promises that we care about have successfully
|
|
|
|
// resolved, so simply exit with success.
|
2023-08-08 15:15:33 +00:00
|
|
|
if (earlyExit) {
|
|
|
|
process.exit(0);
|
|
|
|
}
|
2019-10-30 18:48:49 +00:00
|
|
|
}
|
|
|
|
|
2023-08-08 15:15:33 +00:00
|
|
|
run(true);
|
2019-10-30 18:48:49 +00:00
|
|
|
|
|
|
|
export default run;
|