PHP WebShell
Текущая директория: /opt/BitGoJS/node_modules/nx/src/daemon
Просмотр файла: cache.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDaemonProcessIdSync = exports.safelyCleanUpExistingProcess = exports.writeDaemonJsonProcessCache = exports.deleteDaemonJsonProcessCache = exports.readDaemonProcessJsonCache = exports.serverProcessJsonPath = void 0;
const tslib_1 = require("tslib");
const fs_extra_1 = require("fs-extra");
const path_1 = require("path");
const tmp_dir_1 = require("./tmp-dir");
exports.serverProcessJsonPath = (0, path_1.join)(tmp_dir_1.DAEMON_DIR_FOR_CURRENT_WORKSPACE, 'server-process.json');
function readDaemonProcessJsonCache() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (!(0, fs_extra_1.existsSync)(exports.serverProcessJsonPath)) {
return null;
}
return yield (0, fs_extra_1.readJson)(exports.serverProcessJsonPath);
});
}
exports.readDaemonProcessJsonCache = readDaemonProcessJsonCache;
function deleteDaemonJsonProcessCache() {
try {
if (getDaemonProcessIdSync() === process.pid) {
(0, fs_extra_1.unlinkSync)(exports.serverProcessJsonPath);
}
}
catch (_a) { }
}
exports.deleteDaemonJsonProcessCache = deleteDaemonJsonProcessCache;
function writeDaemonJsonProcessCache(daemonJson) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield (0, fs_extra_1.writeJson)(exports.serverProcessJsonPath, daemonJson);
});
}
exports.writeDaemonJsonProcessCache = writeDaemonJsonProcessCache;
function safelyCleanUpExistingProcess() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const daemonProcessJson = yield readDaemonProcessJsonCache();
if (daemonProcessJson && daemonProcessJson.processId) {
try {
process.kill(daemonProcessJson.processId);
}
catch (_a) { }
}
deleteDaemonJsonProcessCache();
});
}
exports.safelyCleanUpExistingProcess = safelyCleanUpExistingProcess;
// Must be sync for the help output use case
function getDaemonProcessIdSync() {
if (!(0, fs_extra_1.existsSync)(exports.serverProcessJsonPath)) {
return null;
}
try {
const daemonProcessJson = (0, fs_extra_1.readJsonSync)(exports.serverProcessJsonPath);
return daemonProcessJson.processId;
}
catch (_a) {
return null;
}
}
exports.getDaemonProcessIdSync = getDaemonProcessIdSync;
//# sourceMappingURL=cache.js.mapВыполнить команду
Для локальной разработки. Не используйте в интернете!