403Webshell
Server IP : 34.87.99.72  /  Your IP : 216.73.217.31
Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n
System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64
User : bitnami ( 1000)
PHP Version : 7.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/bitnami/nami/node_modules/provisioner/lib/recipes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/bitnami/nami/node_modules/provisioner/lib/recipes/gonit.js
/// <reference path="../../typings-recipe.d.ts" />
/*
 * Recipes for managing gonit
 */
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
// Support Monit configuration paths, used by Bash modules
const monitConfDir = "/etc/monit/conf.d";
const monitConfPattern = `${monitConfDir}/*.conf`;
const gonitConfFile = "/etc/gonit/gonitrc";
const gonitBinary = `${platform.pathInfo.namiAppPath}/gonit/bin/gonit`;
const gonitBinaryLinks = ["/usr/bin/gonit", "/usr/bin/monit"];
const gonitConfigurationHeader = `set httpd port 2812 and
    use address localhost
    allow localhost

include ${monitConfPattern}
`;
/*
 * Helper function for getting list of monit files
 */
function getMonitFiles() {
    // Add Monit configuration for Nami modules, as they don't put them directly inside /etc/monit/conf.d
    const namiMonitFiles = namiRegistry.components.filter(component => {
        // filter the registry to find modules
        return component.monitFile && component.installdir && (component.lifecycle === "installed");
    }).map(component => {
        return $file.join(component.installdir, component.monitFile);
    });
    return namiMonitFiles.concat($file.glob(monitConfPattern));
}
;
const gonitConditions = {
    shouldInvoke: function (input) {
        // only create gonit configuration and run it if there are any services that support it
        return getMonitFiles().length > 0;
    }
};
/*
 * Recipe creating gonit configuration after modules are initialized
 */
recipes.register({
    id: "gonit-configuration",
    on: { afterInitialize: {} },
    conditions: gonitConditions,
    recipeHandler: function (input) {
        const monitFiles = getMonitFiles();
        let configuration = gonitConfigurationHeader;
        for (let filename of monitFiles) {
            // Files in /etc/monit/conf.d will be added dynamically
            if (monitConfDir !== $file.dirname(filename)) {
                configuration += `\ninclude ${filename}`;
            }
        }
        configuration += "\n";
        $file.write(gonitConfFile, configuration);
        $file.chmod(gonitConfFile, "0600");
        // Make gonit available through monit and gonit commands
        for (const link of gonitBinaryLinks) {
            $file.link(gonitBinary, link, { force: true });
        }
    }
});
/**
 * Recipe for starting gonit
 */
recipes.register({
    id: "gonit-start",
    on: { afterStart: {} },
    conditions: gonitConditions,
    recipeHandler: function (input) {
        return __awaiter(this, void 0, void 0, function* () {
            logger.info("Starting gonit monitoring service");
            $os.runProgram(gonitBinary);
            // Wait a couple of seconds for Gonit to be able to properly process the 'monitor all' request
            $os.runProgram("sleep", "2");
            logger.info("Start monitoring all services from gonit");
            yield utils.retry(() => {
                $os.runProgram(gonitBinary, ["monitor", "all"]);
            }, { delay: 2, errorMessage: "Unable to execute 'gonit monitor all'. Retrying...", logger });
        });
    }
});
/**
 * Recipe for stopping gonit
 */
recipes.register({
    id: "gonit-stop",
    on: { beforeStop: {} },
    conditions: gonitConditions,
    recipeHandler: function (input) {
        logger.info("Stop monitoring services from gonit");
        $os.runProgram(gonitBinary, ["unmonitor", "all"]);
    }
});

Youez - 2016 - github.com/yon3zu
LinuXploit