You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Laravel Envoy](https://github.com/laravel/envoy)provides a clean, minimal syntax for defining common tasks you run on your remote servers. Using Blade style syntax, you can easily setup tasks for deployment, Artisan commands, and more. Currently, Envoy only supports the Mac and Linux operating systems.
18
+
[Laravel Envoy](https://github.com/laravel/envoy)为定义在远程服务器上运行的通用任务提供了一种简洁、轻便的语法。它使用了 Blade 风格的语法,让你可以很方便的启动任务来进行项目部署、Artisan 命令运行等操作。目前,Envoy 只支持 Mac 及 Linux 操作系统。
19
19
20
20
<aname="installation"></a>
21
-
### Installation
21
+
### 安装
22
22
23
-
First, install Envoy using the Composer `global require`command:
23
+
首先,使用 Composer `global require`命令来安装 Enovy :
24
24
25
25
composer global require laravel/envoy
26
26
27
-
Since global Composer libraries can sometimes cause package version conflicts, you may wish to consider using `cgr`, which is a drop-in replacement for the `composer global require`command. The `cgr`library's installation instructions can be [found on GitHub](https://github.com/consolidation-org/cgr).
27
+
因为 Composer 的全局库有时会导致包的版本冲突,所以你可以考虑使用 `cgr` ,它是 `composer global require`命令的一种替代实现 `cgr`库的安装指导可以在 [GitHub上找到](https://github.com/consolidation-org/cgr)。
28
28
29
-
> {note} Make sure to place the `~/.composer/vendor/bin`directory in your PATH so the `envoy`executable is found when running the `envoy` command in your terminal.
You may also use Composer to keep your Envoy installation up to date. Issuing the `composer global update`command will update all of your globally installed Composer packages:
33
+
你也可以使用 Composer 来更新 Envoy 到最新版本。 要注意 `composer global update`命令是更新你所有在全局安装的包:
34
34
35
35
composer global update
36
36
37
37
<aname="writing-tasks"></a>
38
-
## Writing Tasks
38
+
## 编写任务
39
39
40
-
All of your Envoy tasks should be defined in an `Envoy.blade.php`file in the root of your project. Here's an example to get you started:
As you can see, an array of `@servers`is defined at the top of the file, allowing you to reference these servers in the `on`option of your task declarations. Within your `@task`declarations, you should place the Bash code that should run on your server when the task is executed.
You can force a script to run locally by specifying the server's IP address as `127.0.0.1`:
50
+
你可以通过指定服务器的 IP 地址为 `127.0.0.1` 来执行本地任务:
51
51
52
52
@servers(['localhost' => '127.0.0.1'])
53
53
54
54
<aname="setup"></a>
55
-
### Setup
55
+
### 任务启动
56
56
57
-
Sometimes, you may need to execute some PHP code before executing your Envoy tasks. You may use the ```@setup```directive to declare variables and do other general PHP work before any of your other tasks are executed:
@@ -71,13 +71,13 @@ If you need to require other PHP files before your task is executed, you may use
71
71
@endtask
72
72
73
73
<aname="variables"></a>
74
-
### Variables
74
+
### 任务变量
75
75
76
-
If needed, you may pass option values into Envoy tasks using the command line:
76
+
如果需要的话,你也可以通过命令行选项来传递变量至 Envoy 文件,以便自定义你的任务:
77
77
78
78
envoy run deploy --branch=master
79
79
80
-
You may access the options in your tasks via Blade's "echo" syntax. Of course, you may also use `if` statements and loops within your tasks. For example, let's verify the presence of the `$branch`variable before executing the `git pull` command:
@@ -92,9 +92,9 @@ You may access the options in your tasks via Blade's "echo" syntax. Of course, y
92
92
@endtask
93
93
94
94
<aname="stories"></a>
95
-
### Stories
95
+
### 任务故事
96
96
97
-
Stories group a set of tasks under a single, convenient name, allowing you to group small, focused tasks into large tasks. For instance, a `deploy`story may run the `git`and`composer`tasks by listing the task names within its definition:
@@ -111,14 +111,14 @@ Stories group a set of tasks under a single, convenient name, allowing you to gr
111
111
composer install
112
112
@endtask
113
113
114
-
Once the story has been written, you may run it just like a typical task:
114
+
当 story 写好后,像运行普通任务一样运行它就好了:
115
115
116
116
envoy run deploy
117
117
118
118
<aname="multiple-servers"></a>
119
-
### Multiple Servers
119
+
### 多个服务器
120
120
121
-
Envoy allows you to easily run a task across multiple servers. First, add additional servers to your `@servers`declaration. Each server should be assigned a unique name. Once you have defined your additional servers, list each of the servers in the task's `on`array:
@@ -128,9 +128,9 @@ Envoy allows you to easily run a task across multiple servers. First, add additi
128
128
php artisan migrate
129
129
@endtask
130
130
131
-
#### Parallel Execution
131
+
#### 并行运行
132
132
133
-
By default, tasks will be executed on each server serially. In other words, a task will finish running on the first server before proceeding to execute on the second server. If you would like to run a task across multiple servers in parallel, add the `parallel`option to your task declaration:
@@ -141,16 +141,16 @@ By default, tasks will be executed on each server serially. In other words, a ta
141
141
@endtask
142
142
143
143
<aname="running-tasks"></a>
144
-
## Running Tasks
144
+
## 运行任务
145
145
146
-
To run a task or story that is defined in your `Envoy.blade.php`file, execute Envoy's `run`command, passing the name of the task or story you would like to execute. Envoy will run the task and display the output from the servers as the task is running:
If you would like to be prompted for confirmation before running a given task on your servers, you should add the `confirm`directive to your task declaration. This option is particularly useful for destructive operations:
@@ -160,21 +160,35 @@ If you would like to be prompted for confirmation before running a given task on
160
160
161
161
<aname="notifications"></a>
162
162
<aname="hipchat-notifications"></a>
163
-
## Notifications
163
+
## 通知
164
164
165
165
<aname="slack"></a>
166
166
### Slack
167
167
168
-
Envoy also supports sending notifications to [Slack](https://slack.com) after each task is executed. The `@slack`directive accepts a Slack hook URL and a channel name. You may retrieve your webhook URL by creating an "Incoming WebHooks" integration in your Slack control panel. You should pass the entire webhook URL into the `@slack`directive:
0 commit comments