远程执行命令 Flightplan
- 授权协议: MIT
- 开发语言: JavaScript
- 操作系统: 跨平台
- 软件首页: https://github.com/pstadler/flightplan
- 软件文档: https://github.com/pstadler/flightplan
软件介绍
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() {
});
热搜:搜索排名营销大揭秘
【美】肖恩·布拉德利 / 中国人民大学出版社有限公司 / 2018-7-30 / CNY 55.00
首部大数据在我国政府管理场景中的应用实践案例读本,全面展示我国电子政务与数字化建设的成果,深度理解实施国家大数据战略的重要意义。 本书作者作为国内最早从事大数据应用研究的实践者之一,亲历了中国大数据的发展历程、主要事件、应用案例以及行业变化。 在本书中,作者将其所亲历的大数据发展历程进行了阐述,从大数据的基本概念、特点到实践解读,通俗易懂,给我们的实际工作提供了重要参考。作者将帮助读者......一起来看看 《热搜:搜索排名营销大揭秘》 这本书的介绍吧!
随机密码生成器
多种字符组合密码
RGB HSV 转换
RGB HSV 互转工具
