Deployer-7-命令行使用-Cli Usage

本文介绍如何使用Deployer进行自动化部署,包括基本命令、配置覆盖、任意命令执行及帮助信息获取。通过Deployer,可以轻松地在不同环境中进行部署,避免误操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装(https://deployer.org/docs/installation)了 Deployer 后,我们可以在终端运行 dep 命令。

为了获取所有可用的任务列表,可以运行 dep 命令。我们可以在项目的任意子目录来运行它;Deployer 将会自动查找项目根目录。

	/*
		Deployer

		Usage:
		  	command [options] [arguments]

		Options:
		  	-h, --help            Display this help message
		  	-q, --quiet           Do not output any message
		  	-V, --version         Display this application version
		      	--ansi            Force ANSI output
		      	--no-ansi         Disable ANSI output
		  	-n, --no-interaction  Do not ask any interactive question
		  	-f, --file[=FILE]     Specify Deployer file
		  	-v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

		Available commands:
		  	help         Displays help for a command
		  	init         Initialize deployer system in your project
		  	list         Lists commands
		  	run          Run any arbitrary command on hosts
		  	self-update  Updates deployer.phar to the latest version
		  	ssh          Connect to host through ssh
	*/
	
配置 deploy.php 的最佳方法是,通过如下命令,自动部署到预演环境:
	dep deploy

这样,有些人就不会意外部署到生产环境中(对于生产环境部署,dep deploy production 命令需要显式列出所需的 production 应用环境)

需要有关可用选项和用法的相关信息,可以使用 help 命令:
	dep help deploy

	/*
		$ dep help deploy
		Usage:
		  	deploy [options] [--] [<stage>]

		Arguments:
		  	stage                      Stage or hostname

		Options:
		  	-p, --parallel             Run tasks in parallel
		  	-l, --limit=LIMIT          How many host to run in parallel?
		      	--no-hooks             Run task without after/before hooks
		      	--log=LOG              Log to file
		      	--roles=ROLES          Roles to deploy
		      	--hosts=HOSTS          Host to deploy, comma separated, supports ranges [:]
		  	-o, --option=OPTION        Sets configuration option (multiple values allowed)
		  	-h, --help                 Display this help message
		  	-q, --quiet                Do not output any message
		  	-V, --version              Display this application version
		      	--ansi                 Force ANSI output
		      	--no-ansi              Disable ANSI output
		  	-n, --no-interaction       Do not ask any interactive question
		  	-f, --file[=FILE]          Specify Deployer file
		      	--tag[=TAG]            Tag to deploy
		      	--revision[=REVISION]  Revision to deploy
		      	--branch[=BRANCH]      Branch to deploy
		  	-v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

		Help:
		  	Deploy your project
	*/

覆盖配置选项
	例如,如果我们的 deploy.php 文件包含如下配置:
		set('ssh_multiplexing', false);

	并且,我们想要在不修改该文件的情况下,开启 ssh multiplexing(https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing),我们可以给 dep 命令,传递 -o 选项:
		dep deploy -o ssh_multiplexing=true

	要覆盖多个配置选项,我们可以传递多个 -o 参数:
		dep deploy -o ssh_multiplexing=true -o branch=master

运行任意命令
	Deployer 附带了一个命令,来运行我们服务器上的任意命令,而不修改 deploy.php 文件。
		dep run 'ls -la'

	要指定主机,该命令具有相应的选项:
		--stage=STAGE    Stage to deploy
		--roles=ROLES    Roles to deploy
		--hosts=HOSTS    Host to deploy, comma separated, supports ranges [:]

获取帮助
	通过使用 help 命令,我们来获取任意命令的更多信息:
		dep help [command]

自动完成
	Deployer 附带了一个 bash/zsh/fish shell 支持的 autocomplete 脚本,因此我们不需要记住所有的任务和选项。运行以下命令来安装:
		dep autocomplete
	
	并按照说明操作


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值