远程执行命令 Flightplan

码农软件 · 软件分类 · Node.js 扩展 · 2019-04-15 19:56:32

软件介绍

Flightplan 可以在本地或者远程主机上运行一序列的命令。这是一个 Node.js 库,用于执行应用发布和系统管理任务,类似 Python 的 Fabric

示例代码:

// flightplan.js
var Flightplan = require('flightplan');

var tmpDir = 'pstadler-sh-' + new Date().getTime();

// configuration
plan.briefing({
    debug: false,
    destinations: {
        'staging': {
            host: 'staging.pstadler.sh',
            username: 'pstadler',
            agent: process.env.SSH_AUTH_SOCK
        },
        'production': [
            {
                host: 'www1.pstadler.sh',
                username: 'pstadler',
                agent: process.env.SSH_AUTH_SOCK
            },
            {
                host: 'www2.pstadler.sh',
                username: 'pstadler',
                agent: process.env.SSH_AUTH_SOCK
            }
        ]
    }
});

// run commands on localhost
plan.domestic(function(local) {
    local.log('Run build');
    local.exec('gulp build');

    local.log('Copy files to remote host');
    var filesToCopy = '(git ls-files -z;find assets/public -type f -print0)';
    local.exec(filesToCopy + '|rsync --files-from - -avz0 --rsh="ssh"'
                + ' ./ pstadler@pstadler.sh:/tmp/' + tmpDir);
});

// run commands on remote hosts (destinations)
plan.international(function(remote) {
    remote.log('Move folder to web root');
    remote.sudo('cp -R /tmp/' + tmpDir + ' ~', { user: 'www' });
    remote.rm('-rf /tmp/' + tmpDir);

    remote.log('Install dependencies');
    remote.sudo('npm --production --silent --prefix ~/'
                    + tmpDir + ' install ~/' + tmpDir, { user: 'www' });

    remote.log('Reload application');
    remote.sudo('ln -snf ~/' + tmpDir + ' ~/pstadler-sh', { user: 'www' });
    remote.sudo('pm2 reload pstadler-sh', { user: 'www' });
});

// run more commands on localhost afterwards
plan.domestic(function(local) { /* ... */ });
// ...or on remote hosts
plan.international(function(remote) { /* ... */ });

// executed if flightplan succeeded
plan.success(function() {
});

// executed if flightplan failed
plan.disaster(function() {
});

// always executed after flightplan finished
plan.debriefing(function() {
});

本文地址:https://codercto.com/soft/d/3660.html

啊哈C语言!逻辑的挑战(修订版)

啊哈C语言!逻辑的挑战(修订版)

啊哈磊 / 电子工业出版社 / 2017-1 / 49

《啊哈C语言!逻辑的挑战(修订版)》是一本非常有趣的编程启蒙书,《啊哈C语言!逻辑的挑战(修订版)》从中小学生的角度来讲述,没有生涩的内容,取而代之的是生动活泼的漫画和风趣幽默的文字。配合超萌的编程软件,《啊哈C语言!逻辑的挑战(修订版)》从开始学习与计算机对话到自己独立制作一个游戏,由浅入深地讲述编程的思维。同时,与计算机展开的逻辑较量一定会让你觉得很有意思。你可以在茶余饭后阅读《啊哈C语言!逻......一起来看看 《啊哈C语言!逻辑的挑战(修订版)》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具