How to use the pm2/lib/Satan.executeRemote function in pm2

To help you get started, we’ve selected a few pm2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yyx990803 / pod / lib / core.js View on Github external
api.listApps = function (callback) {
    var apps = Object.keys(globalConfig.apps)
    if (!apps.length) {
        return callback(null, [])
    }
    Satan.executeRemote('list', {}, function (err, list) {
        if (err) return callback(err)
        callback(null, apps.map(function (appname) {
            var app = api.getAppInfo(appname)
            app.isRunning = findInList(appname, list)
            return app
        }))
    })
}
github yyx990803 / pod / lib / core.js View on Github external
function restart (app, callback) {
    var msg = app.opts.name.yellow + ' restarted'
    if (app.status === 'stopped') {
        Satan.executeRemote('startId', { id: app.pm_id }, function (err) {
            if (err) return callback(err)
            callback(null, msg)
        })
    } else {
        try {
            process.kill(app.pid)
        } catch (err) {
            return callback(err)
        }
        return callback(null, msg)
    }
}
github yyx990803 / pod / lib / core.js View on Github external
Satan.executeRemote('findByScript', {script: app.script}, function (err, proc) {
            if (err) return callback(err)
            if (proc) return callback(null, appname.yellow + ' already running.')

            var appConf = prepareConfig(app)
            appConf.NODE_ENV = app.config.nodeEnv || globalConfig.nodeEnv
            if (app.config.port) appConf.PORT = app.config.port

            Satan.executeRemote('prepare', appConf, function (err) {
                if (err) return callback(err)
                callback(null, appname.yellow + ' running on ' + app.port)
            })
        })
    })
github yyx990803 / pod / lib / core.js View on Github external
Satan.executeRemote('findByScript', {script: app.script}, function (err, proc) {
        if (err) return callback(err)
        if (!proc) return callback(null, appname.yellow + ' is not running')
        Satan.executeRemote('stopId', { id: proc.pm_id }, function (err) {
            if (err) return callback(err)
            callback(null, appname.yellow + ' stopped.')
        })
    })
}
github yyx990803 / pod / lib / core.js View on Github external
api.stopApp = function (appname, callback) {
    var app = api.getAppInfo(appname)
    if (!app) {
        return callback(new Error('app ' + appname.yellow + ' does not exist.'))
    }
    Satan.executeRemote('findByScript', {script: app.script}, function (err, proc) {
        if (err) return callback(err)
        if (!proc) return callback(null, appname.yellow + ' is not running')
        Satan.executeRemote('stopId', { id: proc.pm_id }, function (err) {
            if (err) return callback(err)
            callback(null, appname.yellow + ' stopped.')
        })
    })
}