1

Forge 服务器已链接到 GitLab 存储库。因此,每次我将新提交推送到我的主分支 Gitlab 都会触发 Forge 的部署 URL。

问题似乎是我的部署脚本执行时间过长,这导致 Forge 正在杀死脚本。我可以以某种方式避免杀死部署脚本吗?

我的部署脚本:

cd /home/forge/x.dk
git pull origin master
composer install --no-interaction --no-dev --prefer-dist
npm install
npm install gulp
gulp --production
php artisan migrate --force

部署日志:

From gitlab.com:x/x
 * branch            master     -> FETCH_HEAD
Already up-to-date.
Loading composer repositories with package information
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files
> php artisan clear-compiled
> php artisan optimize
Generating optimized class loader
Compiling common classes
gulp@3.9.0 node_modules/gulp
├── interpret@0.6.6
├── pretty-hrtime@1.0.1
├── deprecated@0.0.1
├── archy@1.0.0
├── tildify@1.1.2 (os-homedir@1.0.1)
├── minimist@1.2.0
├── v8flags@2.0.10 (user-home@1.1.1)
├── chalk@1.1.1 (escape-string-regexp@1.0.3, supports-color@2.0.0, ansi-styles@2.1.0, has-ansi@2.0.0, strip-ansi@3.0.0)
├── semver@4.3.6
├── orchestrator@0.3.7 (stream-consume@0.1.0, sequencify@0.0.7, end-of-stream@0.1.5)
├── liftoff@2.2.0 (extend@2.0.1, rechoir@0.6.2, flagged-respawn@0.3.1, resolve@1.1.6, findup-sync@0.3.0)
├── vinyl-fs@0.3.14 (graceful-fs@3.0.8, strip-bom@1.0.0, vinyl@0.4.6, defaults@1.0.3, mkdirp@0.5.1, through2@0.6.5, glob-stream@3.1.18, glob-watcher@0.0.6)
└── gulp-util@3.0.6 (array-differ@1.0.0, array-uniq@1.0.2, beeper@1.1.0, lodash._reevaluate@3.0.0, lodash._reinterpolate@3.0.0, lodash._reescape@3.0.0, object-assign@3.0.0, replace-ext@0.0.1, vinyl@0.5.3, lodash.template@3.6.2, through2@2.0.0, multipipe@0.1.2, dateformat@1.0.11)
[17:43:36] Using gulpfile ~/x.dk/gulpfile.js
[17:43:36] Starting 'default'...
[17:43:36] Starting 'less'...

Fetching Less Source Files...
   - resources/assets/less/style.less


Saving To...
   - public/css/style.css

[17:43:37] Finished 'default' after 1.02 s
[17:43:41] gulp-notify: [Laravel Elixir] Less Compiled!
[17:43:41] gulp-notify: [Error in notifier] Error in plugin 'gulp-notify'
Message:
    not found: notify-send
[17:43:41] Finished 'less' after 5.15 s
[17:43:41] Starting 'less'...

Fetching Less Source Files...
   - resources/assets/less/admin-style.less


Saving To...
   - public/css/admin-style.css

[17:43:45] gulp-notify: [Laravel Elixir] Less Compiled!
[17:43:45] gulp-notify: [Error in notifier] Error in plugin 'gulp-notify'
Message:
    notify-send must be installed on the system.
[17:43:45] Finished 'less' after 4.18 s
[17:43:45] Starting 'scripts'...

Fetching Scripts Source Files...
   - bower_components/jquery/dist/jquery.min.js
   - bower_components/bootstrap/dist/js/bootstrap.min.js


Saving To...
   - public/js/all.js

/home/forge/.forge/provision-1234567.sh: line 8: 21661 Killed                  gulp --production
4

1 回答 1

0

我会避免在部署脚本中做这些 NPM 的东西:

npm install
npm install gulp

您可能需要通过 SSH 安装 Gulp,然后让部署脚本gulp --production在每次推送时运行。

要通过 SSH 访问您的服务器,请遵循以下 Laracast:https ://laracasts.com/series/server-management-with-forge/episodes/4 。它解释了如何连接到数据库,但基本相同。

当你有 SSH 访问权限时,安装 Gulp:

sudo apt-get update
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
sudo npm install -g gulp

希望能帮助到你。

于 2015-10-14T03:09:20.863 回答