nimbly/minion 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nimbly/minion

最新稳定版本:3.0.3

Composer 安装命令:

composer require nimbly/minion

包简介

Framework and language agnostic remote deployment automation tool

README 文档

README

minion creates a new checkout/clone of your repo for each deployment. This allows clean installs and easy rollbacks to previous releases. The general idea is a single directory holds the releases and a symlink points to the current release.

NOTE: In order for this to work with your webserver (Apache, Nginx, etc), you will need to update its configuration to point to the symlink as its webroot.

During deployment, minion will apply your deployment strategy on each defined server. A deployment strategy is simply a list of tasks you would like minion to run.

minion has several built-in tasks - however, you will need to create and implement your own tasks to take full advantage. Some examples: install composer, run migrations, flush caches, restart web service, restart web application, etc.

Install

composer require nimbly/minion

Initialize

minion make:init

Configure

If you run the make:init command, minion will create a couple directories (Tasks and Commands) as well as generate a default configuration file (minion.yml).

The first several sections of the config file define global config options. Each environment defined may optionally override these global options.

The global sections are:

  • remote
  • authentication
  • code

remote

The remote section defines options on the remote server environment including where to deploy code.

The options for the remote sections are as follows:

  • path [string] The absolute path to the code on the server. I.e. the path to deploy code to.

  • releaseDir [string] The path to keep the releases (relative to path).

  • symlink [string] Name of the symlink to create to point to current release.

  • keepReleases [integer] The number of releases to keep before pruning old releases.

authentication

The authentication section defines how SSH can authenticate with your servers. You can either authenticate with a username and password or using a username, key and (optionally) a key pass phrase.

NOTE: because minion uses PHPSECLIB as its core SSH library, you can only use RSA keys - DSA keys are not supported at this time.

The options for the authentication sections are as follows:

  • username [string] The SSH username to connect with.

  • password [string] optional The SSH password to use (if not using key based authentication).

  • key [string] optional Path and file name of RSA key file.

  • passphrase [string] optional Pass phrase for key (if using key based authentication).

code

The code section defines how and where your code is stored.

  • scm [git, svn] What source code management tool you use.

  • repo [string] Repository URL/location

  • branch [string] optional Repository branch (if any)

  • username [string] optional Repository username

  • password [string] optional Repository password

environments

This section is where you define your server groups or environments. Each environment has a unique name and a list of servers. You must define a deployment strategy and provide an array of servers. A server must have a host property.

  • strategy [string] Comma separated list of tasks to run, in the order specified.
  • servers [array] Array of servers to deploy to
  • preDeploy [string] Comma separated list of tasks to run before the deploy happens. These tasks will be run on the local machine (i.e. not remotely).
  • postDeploy [string] Comma separate list of tasks to run after the deploy happens. These tasks will be run on the local machine (i.e. not remotely).

For example:

environments:
	production:
	    strategy: release, link, prune
		servers:
			- host: web-001.example.com
			- host: web-002.example.com
			- host: web-003.example.com

Within each environment, you may override some or all global options. For example, if your staging environment has a different set of SSH keys used to authenticate and uses the staging branch of your repo, you can define those changes within the staging environment.

For example:

environments:
	staging:
	    strategy: release, link, prune
		code:
			branch: staging
		authentication:
			username: deploy
			key: staging_id_rsa.pub
		servers:
			- host: staging-001.example.com
			- host: staging-002.example.com

A server may also override the environment strategy. This is useful if you have several servers and need to run a migration as it only needs to be run once.

For example:

environments:
	staging:

		code:
			branch: staging
			
		authentication:
			username: deploy
			key: staging_id_rsa.pub
			
		strategy: release, link, prune
			
		servers:
			- host: staging-001.example.com
			  strategy: release, link, migrate, prune
			- host: staging-002.example.com

Tasks

A task is one or more shell commands that are issued on the remote server. minion is pre-configured with four tasks.

  • release Creates a new release on the server.
  • link Symlinks the newly created release to the current release directory (current by default).
  • prune Prunes (deletes) old release directories.
  • update Does a code update on the current release (git pull or svn up)

Extending

minion can be extended by creating new custom commands as well as custom tasks.

Commands

To create a new command:

minion make:command <name>

For example:

minion make:command CacheFlushCommand

Custom commands can be found in the Commands directory where you run minion from.

minion commands are powered by Symfony Console. Please refer to [http://symfony.com/doc/current/components/console.html] for documentation.

Tasks

To create a new task:

minion make:task <name>

For example:

minion make:task Migrate

Custom tasks can be found in the Tasks directory where you run minion from.

nimbly/minion 适用场景与选型建议

nimbly/minion 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.59k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 10 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「php」 「remote」 「deployment」 「automation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nimbly/minion 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nimbly/minion 我们能提供哪些服务?
定制开发 / 二次开发

基于 nimbly/minion 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.59k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-22