4.3. 调试
调试
调查失败的部署
如果部署遇到问题,并且默认输出对你没有帮助的情况下,你可以做一些事情。 首先,尝试使用 --verbose
标志运行正在运行的任何命令。 这将显示更多关于正在发生的事情的信息。
添加的两个主要信息是服务器上运行的命令,以及服务器上实时发生的事情:
$ rocketeer deploy --verbose
|-- Running: Deploy (Deploys the website) [~14.25s]
|---- Running: Primer (Run local checks to ensure deploy can proceed)
|---- Running: CreateRelease (Creates a new release on the server) [~5.98s]
|------ Running strategy for Deploy: Sync
$ mkdir /home/www/myapp/releases/20140817160812
$ rsync ./ user@host:/home/www/myapp/releases/20140817160812 --verbose --recursive --rsh="ssh" --exclude=".git" --exclude="vendor"
[local] building file list ... done
[local] .gitattributes
[local] [...]
[local] sent 970690 bytes received 1910 bytes 84573.91 bytes/sec
[local] total size is 964547 speedup is 0.99
|---- Running: Dependencies (Installs or update the dependencies on server) [~5.15s]
|------ Running strategy for Dependencies: Composer
$ cd /home/www/myapp/releases/20140817160812
$ /usr/local/bin/composer install --no-interaction --no-dev --prefer-dist
[user@host] (production) Loading composer repositories with package information
[user@host] (production) Installing dependencies from lock file
[user@host] (production) [...]
[user@host] (production)
[user@host] (production) Generating autoload files
[user@host] (production) Generating optimized class loader
[user@host] (production) Compiling common classes
[user@host] (production) Compiling views
|---- Running: Migrate (Migrates and/or seed the database) [~0.21s]
|------ Running strategy for Migrate: Artisan
$ rm -rf /home/www/myapp/current
$ ln -s /home/www/myapp/releases/20140817160812 /home/www/myapp/current
Successfully deployed release 20140817160812
|-- Running: Cleanup (Clean up old releases from the server) [~2.68s]
$ rm -rf /home/www/myapp/releases/20140817135635
Removing 1 release from the server
Execution time: 27.4618s
调查缓慢的部署
如果你的部署似乎异常缓慢,我建议你检查每个任务名称旁边括号里显示的时间:
|---- Running: CreateRelease (Creates a new release on the server) [~5.98s]
这个时间是该任务记录的执行时间的平均值。例如你部署了两次,分别用了 10 秒和 8 秒,它会显示为 [~8s]
。 这个时间是个 估值,不代表任务的实际时间,它只是基于之前部署情况的预测。
调查丢失的二进制文件、权限问题等。
如果你发现 Rocketeer 无法执行某个命令,首先,检查你使用相同的证书,能否手动执行该命令。Rocketeer 只做你要求它做的操作,如果你的服务器出现问题影响命令执行,它也会遇到同样的问题。
然而,Rocketeer 和你有一个最大的区别:默认情况下,Rocketeer 将运行在无 shell 会话中。 这意味着它不会使用 Bash 或 Zsh 登录,这对于通过.bashrc
或 .zshrc
文件加载的某些特定工具(如 RVM、NVM 等)是有问题的。
为了解决这个问题,Rocketeer 有一个选项可以在 shell 中运行某些特定命令,你可以在 remote.php
文件中配置它:
// 执行
//////////////////////////////////////////////////////////////////////
// 如果启用,将强制创建 shell
// 这是某些工具(如 RVM 或 NVM)所必需的
'shell' => false,
// 在 shell 下运行的一系列命令
'shelled' => ['npm ', 'bundle ', 'grunt'],
只需启用 shell
选项,并在数组中添加你需要登录的任何命令。 它们与命令匹配,这意味着它只能匹配需执行命令的一部分。
本译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。
推荐文章: