"use strict";
/** @format */
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.execDaemon = void 0;
var path_1 = __importDefault(require("path"));
var child_process_1 = require("child_process");
var core_1 = __importDefault(require("./utils/core"));
var fs = core_1.default.fse;
function execDaemon(filename, config) {
    var filePath = path_1.default.join(__dirname, 'daemon', filename);
    if (!fs.existsSync(filePath))
        return;
    var subprocess = (0, child_process_1.spawn)(process.execPath, [filePath], {
        detached: true,
        stdio: 'ignore',
        env: __assign(__assign({}, process.env), config),
    });
    subprocess.unref();
}
exports.execDaemon = execDaemon;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY0RhZW1vbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9leGVjRGFlbW9uLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxjQUFjOzs7Ozs7Ozs7Ozs7Ozs7OztBQUVkLDhDQUF3QjtBQUN4QiwrQ0FBc0M7QUFDdEMsc0RBQWdDO0FBQ3hCLElBQUssRUFBRSxHQUFLLGNBQUksSUFBVCxDQUFVO0FBS3pCLFNBQWdCLFVBQVUsQ0FBQyxRQUFnQixFQUFFLE1BQWdCO0lBQzNELElBQU0sUUFBUSxHQUFHLGNBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLFFBQVEsRUFBRSxRQUFRLENBQUMsQ0FBQztJQUMxRCxJQUFJLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxRQUFRLENBQUM7UUFBRSxPQUFPO0lBQ3JDLElBQU0sVUFBVSxHQUFHLElBQUEscUJBQUssRUFBQyxPQUFPLENBQUMsUUFBUSxFQUFFLENBQUMsUUFBUSxDQUFDLEVBQUU7UUFDckQsUUFBUSxFQUFFLElBQUk7UUFDZCxLQUFLLEVBQUUsUUFBUTtRQUNmLEdBQUcsd0JBQU8sT0FBTyxDQUFDLEdBQUcsR0FBSyxNQUFNLENBQUU7S0FDbkMsQ0FBQyxDQUFDO0lBQ0gsVUFBVSxDQUFDLEtBQUssRUFBRSxDQUFDO0FBQ3JCLENBQUM7QUFURCxnQ0FTQyJ9