远程执行命令 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

CASIO fx-5800P编程计算器公路与铁路施工测量程序

CASIO fx-5800P编程计算器公路与铁路施工测量程序

2011-8 / 40.00元

《CASIO fx-5800P 编程计算器公路与铁路施工测量程序(第2版)》内容简介:第2版是一本全新的图书。书中的QH2-7T与QH2-8T程序都具有三维中边桩坐标正、反算,路基超高及边桩设计高程计算,边坡坡口与坡脚计算,桥墩桩基坐标计算,隧道超欠挖计算等功能。QH2-7T为交点法程序,QH2-8T为线元法程序,两个程序均使用数据库子程序输入平竖曲线的全部设计数据。测试程序各项功能所用的案例均取......一起来看看 《CASIO fx-5800P编程计算器公路与铁路施工测量程序》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具