T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/.local/lib/code-server-4.102.2/out/node/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/.local/lib/code-server-4.102.2/out/node/heart.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Heart = void 0;
exports.heartbeatTimer = heartbeatTimer;
const logger_1 = require("@coder/logger");
const fs_1 = require("fs");
/**
 * Provides a heartbeat using a local file to indicate activity.
 */
class Heart {
    constructor(heartbeatPath, isActive) {
        this.heartbeatPath = heartbeatPath;
        this.isActive = isActive;
        this.heartbeatInterval = 60000;
        this.lastHeartbeat = 0;
        this.beat = this.beat.bind(this);
        this.alive = this.alive.bind(this);
    }
    alive() {
        const now = Date.now();
        return now - this.lastHeartbeat < this.heartbeatInterval;
    }
    /**
     * Write to the heartbeat file if we haven't already done so within the
     * timeout and start or reset a timer that keeps running as long as there is
     * activity. Failures are logged as warnings.
     */
    beat() {
        return __awaiter(this, void 0, void 0, function* () {
            if (this.alive()) {
                return;
            }
            logger_1.logger.debug("heartbeat");
            this.lastHeartbeat = Date.now();
            if (typeof this.heartbeatTimer !== "undefined") {
                clearTimeout(this.heartbeatTimer);
            }
            this.heartbeatTimer = setTimeout(() => heartbeatTimer(this.isActive, this.beat), this.heartbeatInterval);
            try {
                return yield fs_1.promises.writeFile(this.heartbeatPath, "");
            }
            catch (error) {
                logger_1.logger.warn(error.message);
            }
        });
    }
    /**
     * Call to clear any heartbeatTimer for shutdown.
     */
    dispose() {
        if (typeof this.heartbeatTimer !== "undefined") {
            clearTimeout(this.heartbeatTimer);
        }
    }
}
exports.Heart = Heart;
/**
 * Helper function for the heartbeatTimer.
 *
 * If heartbeat is active, call beat. Otherwise do nothing.
 *
 * Extracted to make it easier to test.
 */
function heartbeatTimer(isActive, beat) {
    return __awaiter(this, void 0, void 0, function* () {
        try {
            if (yield isActive()) {
                beat();
            }
        }
        catch (error) {
            logger_1.logger.warn(error.message);
        }
    });
}
//# sourceMappingURL=heart.js.map

CasperSecurity Mini