assimtech / tempo
PHP项目的部署工具
0.3.1
2016-10-05 00:23 UTC
Requires
- php: >=5.3.3
- assimtech/sysexits: ^1.0
- symfony/console: ^2.3|^3.0
- symfony/finder: ^2.3|^3.0
- symfony/process: ^2.3|^3.0
- symfony/yaml: ^2.3|^3.0
Requires (Dev)
- henrikbjorn/phpspec-code-coverage: ^1.0
- phpmd/phpmd: ^2.2
- phpspec/phpspec: ^2.2
- sebastian/phpcpd: ^2.0
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-09-10 14:10:54 UTC
README
PHP项目的部署工具。使用php
在本地和远程节点上执行命令。
快速开始
使用composer将tempo安装到您的项目中
composer require assimtech/tempo
在项目的根目录中创建一个名为tempo.php
的文件,内容如下
<?php use Assimtech\Tempo; use MyProject\Tempo\Command; // Infrastructure $infrastructureLoader = Tempo\Factory\InfrastructureLoaderFactory::create(); $infrastructure = $infrastructureLoader->load(__DIR__ . '/infrastructure.yml'); // Commands $definition = new Tempo\Definition(); foreach ($infrastructure->getEnvironments() as $env) { $definition->addCommand(new Command\WhereAmI($env)); } return $definition;
然后创建一个名为infrastructure.yml
的文件,内容如下
nodes: server1: ssh: host: server1.example.com environments: - name: test nodes: [ server1 ]
将"server1.example.com"更改为您有权SSH访问的服务器。如果您需要更改用户名/端口等,请参阅有关如何设置节点的文档
然后创建一个名为MyProject\Tempo\Command\WhereAmI
的类,内容如下
<?php namespace MyProject\Tempo\Command; use Assimtech\Sysexits; use Assimtech\Tempo\Command\AbstractCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class WhereAmI extends AbstractCommand { /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { foreach ($this->env->getNodes() as $node) { $output->write("<comment>Checking uname of $node: </comment>"); $uname = $node->run('uname -a'); $output->writeln("<info>$uname</info>"); } return Sysexits::EX_OK; } }
在项目的根目录下运行tempo
tempo test:whereami
尝试添加更多环境/服务器/命令等
已知问题
从Docker容器中运行tempo可能会导致连接问题
由于最新版本的ssh与overlayfs不兼容的问题,您可能会遇到像Control socket connect(...): Connection refused
这样的连接共享问题
如果运行的脚本似乎在每次远程命令中都进行身份验证,或者如果每次命令响应中都看到MOTD,这也可能是原因。
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1262287
如果您有此问题,您可以在infrastructure.yml
中将您的控制主路径指定为标准文件系统位置(容器中的任何位置,只要不在主机目录卷之外)
nodes: server1: ssh: host: server1.example.com control: ControlPath: /tmp/%r@%h:%p environments: - name: test nodes: [ server1 ]