From 5878a2c732be7901fe01450c372eb15a3e3e3d63 Mon Sep 17 00:00:00 2001 From: Giulio Micheloni Date: Mon, 8 May 2023 22:03:36 +0200 Subject: [PATCH] post: check if pid file exists before reading it --- dist/post/index.js | 6 ++++-- post.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dist/post/index.js b/dist/post/index.js index cf211df..cb740f9 100644 --- a/dist/post/index.js +++ b/dist/post/index.js @@ -2881,8 +2881,10 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume function run() { return __awaiter(this, void 0, void 0, function* () { try { - const pid = external_fs_.readFileSync(ProxyPidFile, "utf8"); - process.kill(parseInt(pid), "SIGINT"); + if (external_fs_.existsSync(ProxyPidFile)) { + const pid = external_fs_.readFileSync(ProxyPidFile, "utf8"); + process.kill(parseInt(pid), "SIGINT"); + } } catch (error) { core.setFailed(error.message); diff --git a/post.ts b/post.ts index c1d3676..0b668bd 100644 --- a/post.ts +++ b/post.ts @@ -4,8 +4,10 @@ import { ProxyPidFile } from "./common"; async function run(): Promise { try { - const pid = fs.readFileSync(ProxyPidFile, "utf8"); - process.kill(parseInt(pid), "SIGINT"); + if (fs.existsSync(ProxyPidFile)) { + const pid = fs.readFileSync(ProxyPidFile, "utf8"); + process.kill(parseInt(pid), "SIGINT"); + } } catch (error) { core.setFailed(error.message); }