capistrano-laravel-lazy 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7b441d61f122b8718af54a5e3add2b942dc73c2b
4
+ data.tar.gz: 1ba75866b5bf3280972f03df3b4f9af0574c1fd0
5
+ SHA512:
6
+ metadata.gz: 477c2a3fb627e4682492e5a9dcb7fe6c9794fb62bf68b78fc0b3ead7b5ee0f25477224e1564a7a9a0a98c52e0eb088bb568bd747934806e923ab551e12335b6c
7
+ data.tar.gz: f691ac7154afa74909803784ba8270ff8ffc43e93b523fc0e3176abcf66e7dff823b2498007613c3d8b2779d030eb19c0bb44f420563b7a18ed0cf38c68e774d
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in capistrano-bundler.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Peter Mitchell (peterjmit@gmail.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # Capistrano::laravel
2
+
3
+ Deploy Laravel applications with Capistrano v3.*
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano', '~> 3.0.0'
11
+ gem 'capistrano-laravel'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install capistrano-laravel
21
+
22
+ ## Usage
23
+
24
+ Require the module in your `Capfile`:
25
+
26
+ ```ruby
27
+ require 'capistrano/laravel'
28
+ ```
29
+
30
+ ### Configuration
31
+
32
+ The gem makes the following configuration variables available (shown with defaults).
33
+
34
+ ```ruby
35
+ # Which roles to execute commands on.
36
+ set :laravel_roles, :all
37
+
38
+ # Determines which operations to perform based on which version
39
+ # of the Laravel framework your project is using.
40
+ set :laravel_version, 5.1
41
+
42
+ # If using Laravel 5+, a dotenv file is used for environment configuration.
43
+ # This variable uploads the given file from the the host to the guest.
44
+ set :laravel_dotenv_file, './.env'
45
+
46
+ # Flags to add to artisan calls.
47
+ set :laravel_artisan_flags, "--env=production"
48
+
49
+ # Will set linked folders based on your Laravel version
50
+ set :laravel_set_linked_dirs, false
51
+
52
+ # Will set ACL paths based on your Laravel version
53
+ set :laravel_set_acl_paths, true
54
+
55
+ # Which user to set ACL permissions for.
56
+ set :laravel_server_user, "www-data"
57
+ ```
58
+
59
+ ### Tasks
60
+
61
+ The tasks are more or less automatic and are executed as follows:
62
+
63
+ ```ruby
64
+ before "deploy:starting", :prepare_laravel do
65
+ invoke "laravel:configure_folders"
66
+ end
67
+
68
+ before "deploy:updated", :laravel_tasks do
69
+ invoke "laravel:upload_dotenv_file"
70
+ invoke "laravel:optimize_release"
71
+ invoke "laravel:create_acl_paths"
72
+ invoke "deploy:set_permissions:acl"
73
+ end
74
+ ```
75
+
76
+ #### Task Descriptions
77
+
78
+ ```ruby
79
+ # Execute an artisan command
80
+ invoke "laravel:artisan", "command"
81
+
82
+ # Run any optimization commands
83
+ invoke "laravel:optimize_release"
84
+
85
+ # Configure linked dirs/acl dirs
86
+ invoke "laravel:configure_folders"
87
+
88
+ # Upload the dotenv file from local to remote
89
+ invoke "laravel:upload_dotenv_file"
90
+
91
+ # Seed the database
92
+ invoke "laravel:seed_db"
93
+
94
+ # Create any missing folders for ACL
95
+ invoke "laravel:create_acl_paths"
96
+
97
+ # Run migrations for the database
98
+ invoke "laravel:migrate_db"
99
+ ```
100
+
101
+ ## Contributing
102
+
103
+ 1. Fork it
104
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
105
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
106
+ 4. Push to the branch (`git push origin my-new-feature`)
107
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
data/bin/cap_laravel ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'erb'
4
+ require 'pathname'
5
+ require 'capistrano/all'
6
+
7
+ # desc 'Install Capistrano Laravel, cap_laravel install STAGES=staging,production'
8
+ def laravel_install(stages = 'staging,production')
9
+ config_dir = Pathname.new('config')
10
+ deploy_dir = config_dir.join('deploy')
11
+
12
+ deploy_rb = File.expand_path('../../lib/capistrano/templates/deploy.rb.erb', __FILE__)
13
+ stage_rb = File.expand_path('../../lib/capistrano/templates/stage.rb.erb', __FILE__)
14
+ capfile = File.expand_path('../../lib/capistrano/templates/Capfile', __FILE__)
15
+
16
+ mkdir_p deploy_dir
17
+
18
+ entries = [{template: deploy_rb, file: config_dir.join('deploy.rb')}]
19
+ entries += stages.split(',').map { |stage| {template: stage_rb, file: deploy_dir.join("#{stage}.rb"), stage: stage} }
20
+
21
+ entries.each do |entry|
22
+ if File.exists?(entry[:file])
23
+ warn "[skip] #{entry[:file]} already exists"
24
+ else
25
+ File.open(entry[:file], 'w+') do |f|
26
+ f.write(ERB.new(File.read(entry[:template])).result(binding))
27
+ puts I18n.t(:written_file, scope: :capistrano, file: entry[:file])
28
+ end
29
+ end
30
+ end
31
+
32
+ if File.exists?('Capfile')
33
+ warn '[skip] Capfile already exists'
34
+ else
35
+ FileUtils.cp(capfile, 'Capfile')
36
+ puts I18n.t(:written_file, scope: :capistrano, file: 'Capfile')
37
+ end
38
+
39
+
40
+ puts I18n.t :capified, scope: :capistrano
41
+ end
42
+
43
+ case ARGV[0]
44
+ when 'install'
45
+ if /^STAGES=/ === ARGV[1]
46
+ laravel_install ARGV[1][7,140]
47
+ else
48
+ laravel_install
49
+ end
50
+ else
51
+ puts <<-HERE
52
+
53
+ Install capistrano laravel in a project:
54
+ bundle exec cap_laravel install [STAGES=qa,staging,production,...]
55
+
56
+ Command `cap_laravel` must be used to install capistrano/laravel only!
57
+
58
+ Install capistrano in a project:
59
+ bundle exec cap install [STAGES=qa,staging,production,...]
60
+
61
+ See full capistrano documentation at http://capistranorb.com/.
62
+
63
+ HERE
64
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'capistrano-laravel-lazy'
7
+ spec.version = '0.0.3'
8
+ spec.authors = ['Ivan Chou', 'Peter Mitchell', 'Andrew Miller']
9
+ spec.email = ['yiichou@gmail.com', 'peterjmit@gmail.com', 'ikari7789@yahoo.com']
10
+ spec.description = %q{Laravel specific deployment options for Capistrano 3.x}
11
+ spec.summary = %q{Laravel deployment for Capistrano 3.x}
12
+ spec.homepage = 'https://github.com/IvanChou/laravel/tree/lazy'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'capistrano', '~> 3.0'
21
+ spec.add_dependency 'capistrano-composer', '~> 0.0.6'
22
+ spec.add_dependency 'capistrano-file-permissions', '~> 1.0'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.3'
25
+ spec.add_development_dependency 'rake', '~> 10.4'
26
+ end
@@ -0,0 +1,6 @@
1
+ module Capistrano
2
+ module Laravel
3
+ module Helpers
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Laravel
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ require "capistrano/composer"
2
+ require "capistrano/file-permissions"
3
+
4
+ load File.expand_path("../tasks/laravel.rake", __FILE__)
5
+ load File.expand_path("../tasks/php_fpm.rake", __FILE__)
6
+ load File.expand_path("../tasks/setup_config.rake", __FILE__)
@@ -0,0 +1,185 @@
1
+ require 'capistrano/laravel/helpers'
2
+
3
+ include Comparable
4
+ include Capistrano::Laravel::Helpers
5
+
6
+ namespace :load do
7
+ task :defaults do
8
+ set :laravel_roles, :all
9
+ set :laravel_migrate_roles, :all
10
+ set :laravel_version, 5.1
11
+ set :laravel_dotenv_file, './.env.example'
12
+ set :laravel_artisan_flags, '--env=production'
13
+ set :laravel_artisan_migrate_flags, '--env=production --force'
14
+ set :laravel_set_linked_dirs, true
15
+ set :laravel_set_acl_paths, true
16
+ set :laravel_create_linked_acl_paths, true
17
+ set :laravel_server_user, 'www-data'
18
+ set :laravel_phplint, false
19
+
20
+ # Folders to link between releases
21
+ set :laravel_4_linked_dirs, [
22
+ 'app/storage'
23
+ ]
24
+ set :laravel_5_linked_dirs, [
25
+ 'storage'
26
+ ]
27
+ set :laravel_5_1_linked_dirs, [
28
+ 'storage'
29
+ ]
30
+
31
+ # Folders to set permissions on based on laravel version
32
+ set :laravel_4_acl_paths, [
33
+ 'app/storage',
34
+ 'app/storage/cache',
35
+ 'app/storage/logs',
36
+ 'app/storage/meta',
37
+ 'app/storage/sessions',
38
+ 'app/storage/views'
39
+ ]
40
+ set :laravel_5_acl_paths, [
41
+ 'storage',
42
+ 'storage/app',
43
+ 'storage/framework',
44
+ 'storage/framework/cache',
45
+ 'storage/framework/sessions',
46
+ 'storage/framework/views',
47
+ 'storage/logs'
48
+ ]
49
+ set :laravel_5_1_acl_paths, [
50
+ 'bootstrap/cache',
51
+ 'storage',
52
+ 'storage/app',
53
+ 'storage/framework',
54
+ 'storage/framework/cache',
55
+ 'storage/framework/sessions',
56
+ 'storage/framework/views',
57
+ 'storage/logs'
58
+ ]
59
+ end
60
+ end
61
+
62
+ namespace :laravel do
63
+ desc 'Set the ACL for the web user based on Laravel version.'
64
+ task :configure_folders do
65
+ laravel_version = fetch(:laravel_version)
66
+ laravel_linked_dirs = []
67
+ laravel_acl_paths = []
68
+ if laravel_version < 5 # Laravel 4
69
+ laravel_linked_dirs = fetch(:laravel_4_linked_dirs)
70
+ laravel_acl_paths = fetch(:laravel_4_acl_paths)
71
+ elsif laravel_version < 5.1 # Laravel 5
72
+ laravel_linked_dirs = fetch(:laravel_5_linked_dirs)
73
+ laravel_acl_paths = fetch(:laravel_5_acl_paths)
74
+ else # Laravel 5.1 or greater
75
+ laravel_linked_dirs = fetch(:laravel_5_1_linked_dirs)
76
+ laravel_acl_paths = fetch(:laravel_5_1_acl_paths)
77
+ end
78
+
79
+ if fetch(:laravel_set_linked_dirs)
80
+ set :linked_dirs, fetch(:linked_dirs, []).push(*laravel_linked_dirs)
81
+ end
82
+
83
+ if fetch(:laravel_set_acl_paths)
84
+ set :file_permissions_paths, fetch(:file_permissions_paths, []).push(*laravel_acl_paths)
85
+ set :file_permissions_users, [fetch(:laravel_server_user)]
86
+ end
87
+ end
88
+
89
+ desc 'Create missing directories.'
90
+ task :create_linked_acl_paths do
91
+ if fetch(:laravel_create_linked_acl_paths)
92
+ if fetch(:laravel_version) < 5
93
+ laravel_acl_paths = fetch(:laravel_4_acl_paths)
94
+ elsif fetch(:laravel_version) < 5.1
95
+ laravel_acl_paths = fetch(:laravel_5_acl_paths)
96
+ else
97
+ laravel_acl_paths = fetch(:laravel_5_1_acl_paths)
98
+ end
99
+
100
+ on roles fetch(:laravel_roles) do
101
+ laravel_acl_paths.each do |path|
102
+ acl_path = release_path.join(path)
103
+ if test("[ ! -e '#{acl_path}' ]")
104
+ execute :mkdir, '-vp', acl_path
105
+ else
106
+ info "#{acl_path} already exists."
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+
113
+ desc 'Upload dotenv file for release.'
114
+ task :upload_dotenv_file do
115
+ if fetch(:laravel_version) >= 5
116
+ on roles fetch(:laravel_roles) do
117
+ unless fetch(:laravel_dotenv_file).empty?
118
+ upload! fetch(:laravel_dotenv_file), "#{release_path}/.env"
119
+ end
120
+ end
121
+ end
122
+ end
123
+
124
+ desc 'Execute a provided artisan command'
125
+ task :artisan, :command_name do |_t, args|
126
+ # ask only runs if argument is not provided
127
+ ask(:cmd, 'list')
128
+ command = args[:command_name] || fetch(:cmd)
129
+
130
+ on roles fetch(:laravel_roles) do
131
+ within release_path do
132
+ execute :php, :artisan, command, *args.extras, fetch(:laravel_artisan_flags)
133
+ end
134
+ end
135
+
136
+ # enable task artisan to be ran twice
137
+ Rake::Task['laravel:artisan'].reenable
138
+ end
139
+
140
+ desc 'Optimize the configuration'
141
+ task :optimize_config do
142
+ invoke 'laravel:artisan', 'config:cache' if fetch(:laravel_version) >= 5
143
+ end
144
+
145
+ desc 'Optimize the routing file'
146
+ task :optimize_route do
147
+ invoke 'laravel:artisan', 'route:cache' if fetch(:laravel_version) >= 5
148
+ end
149
+
150
+ desc 'Optimize a Laravel installation for optimimum performance in production.'
151
+ task :optimize_release do
152
+ invoke 'laravel:artisan', :optimize, :'--force'
153
+ end
154
+
155
+ desc 'Run migrations against the database using Artisan.'
156
+ task :migrate_db do |_t, args|
157
+ on roles fetch(:laravel_migrate_roles) do
158
+ within release_path do
159
+ execute :php, :artisan, :migrate, *args.extras, fetch(:laravel_artisan_migrate_flags)
160
+ end
161
+ end
162
+ end
163
+
164
+ desc 'Rollback migrations against the database using Artisan.'
165
+ task :rollback_db do
166
+ on roles fetch(:laravel_migrate_roles) do
167
+ within release_path do
168
+ execute :php, :artisan, 'migrate:rollback', *args.extras, fetch(:laravel_artisan_migrate_flags)
169
+ end
170
+ end
171
+ end
172
+
173
+ desc 'Check syntax error with PHPLint.'
174
+ task :phplint do
175
+ invoke 'laravel:artisan', :phplint if fetch(:laravel_phplint)
176
+ end
177
+
178
+ before 'deploy:starting', 'laravel:configure_folders'
179
+ after 'deploy:symlink:shared', 'laravel:create_linked_acl_paths'
180
+ after 'deploy:symlink:shared', 'deploy:set_permissions:acl'
181
+ # after 'deploy:symlink:shared', 'laravel:upload_dotenv_file'
182
+ before 'deploy:updated', 'laravel:phplint'
183
+ after 'deploy:updated', 'laravel:optimize_release'
184
+
185
+ end
@@ -0,0 +1,15 @@
1
+ namespace :php_fpm do
2
+ %w(start stop status restart reload force-reload).each do |command|
3
+ desc "Commands for #{command} php_fpm"
4
+ task command.to_sym do
5
+ if (fpm = fetch(:php_fpm, 'php5-fpm')).empty?
6
+ warn 'miss setting :php_fpm.'
7
+ else
8
+ on roles(:app), in: :sequence, wait: 1 do
9
+ execute :sudo, "service #{fpm} #{command}"
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ end
@@ -0,0 +1,83 @@
1
+ namespace :load do
2
+ task :defaults do
3
+ set :server_name, 'localhost'
4
+ set :nginx_user, 'nginx'
5
+ set :bind, "unix:/run/php/#{fetch(:php_fpm, 'php5-fpm')}.sock"
6
+ end
7
+ end
8
+
9
+ namespace :deploy do
10
+
11
+ def render_template(file)
12
+ StringIO.new(ERB.new(File.read(file)).result(binding))
13
+ end
14
+
15
+ def upload_shared
16
+ local_shared_path = 'config/deploy/shared'
17
+
18
+ files = Dir.entries local_shared_path
19
+ files.shift(2)
20
+
21
+ files.each do |name|
22
+ local = File.join(local_shared_path, name)
23
+ target = File.join(shared_path, name)
24
+
25
+ if File.file? local
26
+ if local[-4,4] == '.erb'
27
+ local = render_template local
28
+ target = target.gsub('.erb', '')
29
+ end
30
+ upload! local, target
31
+ info "copying: #{name} to: #{target}"
32
+
33
+ elsif File.directory? local
34
+ target = shared_path
35
+ upload! local, target, recursive: true
36
+ info "copying: #{name} to: #{target}"
37
+
38
+ else
39
+ error "error #{local} not found"
40
+ end
41
+ end
42
+ end
43
+
44
+ def upload_config(conf, path)
45
+ if File.exist? "config/templates/#{conf}.erb"
46
+ conf_file = render_template "config/templates/#{conf}.erb"
47
+ elsif File.exist? "config/templates/#{conf}"
48
+ conf_file = "config/templates/#{conf}"
49
+ else
50
+ conf_file = render_template File.expand_path("../../templates/#{conf}.erb", __FILE__)
51
+ end
52
+
53
+ tmp_target = "/tmp/#{fetch(:application)}/#{fetch(:full_app_name)}.#{conf}"
54
+ target = File.join(path, "#{fetch(:full_app_name)}.conf")
55
+ upload! conf_file, tmp_target
56
+ execute :sudo, :mv, "-n #{tmp_target} #{target}"
57
+ info "Compile & upload #{conf} to: #{target}"
58
+ end
59
+
60
+ desc 'setup config to prepare deploying project.'
61
+ task :setup_config do
62
+ on release_roles :all do
63
+ execute :mkdir, "-p #{shared_path}"
64
+
65
+ # compile & upload all the config files
66
+ upload_shared if File.exist? 'config/deploy/shared'
67
+
68
+ # Compile & upload nginx config
69
+ upload_config 'nginx.conf', fetch(:nginx_server_path) unless fetch(:nginx_server_path).to_s.empty?
70
+
71
+ # Compile & upload php-fpm config
72
+ upload_config 'fpm.conf', fetch(:fpm_pool_path) unless fetch(:fpm_pool_path).to_s.empty?
73
+
74
+ # Upload dotenv file to shared path
75
+ if fetch(:laravel_version) >= 5
76
+ unless fetch(:laravel_dotenv_file).empty?
77
+ upload! fetch(:laravel_dotenv_file), "#{shared_path}/.env"
78
+ end
79
+ end
80
+
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,16 @@
1
+ # Load DSL and set up stages
2
+ require 'capistrano/setup'
3
+
4
+ # Include default deployment tasks
5
+ require 'capistrano/deploy'
6
+
7
+ # Include tasks from other gems included in your Gemfile
8
+ #
9
+ # For documentation on these, see for example:
10
+ #
11
+ # https://github.com/capistrano/laravel
12
+ #
13
+ require 'capistrano/laravel'
14
+
15
+ # Load custom tasks from `lib/capistrano/tasks` if you have any defined
16
+ Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
@@ -0,0 +1,61 @@
1
+ # config valid only for current version of Capistrano
2
+ lock '<%= Capistrano::VERSION %>'
3
+
4
+ set :application, 'my_app_name'
5
+ set :repo_url, 'git@example.com:me/my_repo.git'
6
+
7
+ # Default branch is :master
8
+ # ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
9
+
10
+ # Default deploy_to directory is /var/www/my_app_name
11
+ # set :deploy_to, '/var/www/my_app_name'
12
+
13
+ # Default value for :scm is :git
14
+ # set :scm, :git
15
+
16
+ # Default value for :format is :pretty
17
+ # set :format, :pretty
18
+
19
+ # Default value for :log_level is :debug
20
+ # set :log_level, :debug
21
+
22
+ # Default value for :pty is false
23
+ set :pty, true
24
+
25
+ # Default value for :linked_files is []
26
+ set :linked_files, ['.env']
27
+
28
+ # Default value for linked_dirs is []
29
+ # set :linked_dirs, []
30
+
31
+ # Default value for keep_releases is 5
32
+ set :keep_releases, 10
33
+
34
+ # Default value for php_fpm is php5-fpm
35
+ set :php_fpm, 'php7.0-fpm'
36
+
37
+ # Which roles to execute commands on.
38
+ set :laravel_roles, :app
39
+ set :laravel_migrate_roles, :db
40
+
41
+ # Default value for :laravel_version is 5.1
42
+ set :laravel_version, 5.2
43
+
44
+ # If using Laravel 5+, a dotenv file is used for environment configuration.
45
+ # This variable uploads the given file from local to servers, default: './.env.example'
46
+ # set :laravel_dotenv_file, './.env.example'
47
+
48
+ # Default value for :laravel_server_user is true
49
+ # set :laravel_server_user, 'www-data'
50
+
51
+ # Default value for :laravel_phplint is false
52
+ # set :laravel_phplint, false
53
+
54
+ # See more configuration at https://github.com/capistrano/laravel.
55
+
56
+ namespace :deploy do
57
+ after 'deploy:updated', 'laravel:migrate_db'
58
+ after 'deploy:updated', 'laravel:optimize_config'
59
+ after 'deploy:updated', 'laravel:optimize_route'
60
+ after :finishing, 'php_fpm:reload'
61
+ end
@@ -0,0 +1,65 @@
1
+ [<%= fetch(:full_app_name) %>]
2
+
3
+ ;prefix = /path/to/pools/$pool
4
+
5
+ user = <%= fetch(:laravel_server_user) %>
6
+ group = <%= fetch(:laravel_server_user) %>
7
+
8
+ listen = <%= fetch(:bind).gsub('unix:', '') %>
9
+
10
+ ;listen.backlog = 511
11
+
12
+ listen.owner = <%= fetch(:nginx_user) %>
13
+ listen.group = <%= fetch(:nginx_user) %>
14
+ ;listen.mode = 0660
15
+
16
+ ;listen.acl_users =
17
+ ;listen.acl_groups =
18
+
19
+ ;listen.allowed_clients = 127.0.0.1
20
+
21
+ ;process.priority = -19
22
+
23
+ pm = dynamic
24
+ pm.max_children = 5
25
+ pm.start_servers = 2
26
+ pm.min_spare_servers = 1
27
+ pm.max_spare_servers = 3
28
+ ;pm.process_idle_timeout = 10s;
29
+ pm.max_requests = 7200
30
+
31
+ ;pm.status_path = /status
32
+ ;ping.path = /ping
33
+ ;ping.response = pong
34
+
35
+
36
+ access.log = /data/logs/fpm/$pool.log.access;
37
+ access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
38
+ ;access.format = "[%{mili}dms] [%{%Y/%m/%d %H:%M:%S}t] %R - %m %s \"%r%Q%q\""
39
+
40
+ ;slowlog = /data/logs/fpm/$pool.log.slow
41
+ ;request_slowlog_timeout = 0
42
+ ;request_terminate_timeout = 0
43
+
44
+ ;rlimit_files = 1024
45
+ ;rlimit_core = 0
46
+
47
+ ;chroot =
48
+ ;chdir = /var/www
49
+
50
+ ;catch_workers_output = yes
51
+ ;clear_env = no
52
+ security.limit_extensions = .php .php3 .php4 .php5 .php7
53
+
54
+ ;env[HOSTNAME] = $HOSTNAME
55
+ ;env[PATH] = /usr/local/bin:/usr/bin:/bin
56
+ ;env[TMP] = /tmp
57
+ ;env[TMPDIR] = /tmp
58
+ ;env[TEMP] = /tmp
59
+
60
+ ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
61
+ php_admin_flag[display_errors] = off
62
+ php_admin_value[error_reporting] = E_ERROR | E_PARSE | E_CORE_ERROR
63
+ php_admin_value[error_log] = /data/logs/fpm/$pool.log.error
64
+ php_admin_flag[log_errors] = on
65
+ ;php_admin_value[memory_limit] = 32M
@@ -0,0 +1,51 @@
1
+ log_format customized_<%= fetch(:application) %>
2
+ '$remote_addr:$remote_port '
3
+ '$tcpinfo_rtt(±$tcpinfo_rttvar)μs '
4
+ '[$time_iso8601] $request_time "$request" '
5
+ '$status $body_bytes_sent "$http_referer" '
6
+ '"$http_user_agent" "$http_x_forwarded_for" '
7
+ 'UPSTREAM $upstream_addr $upstream_response_time $upstream_status';
8
+
9
+ server {
10
+ listen 80;
11
+ server_name <%= fetch(:server_name) %>;
12
+ root <%= fetch(:deploy_to) %>/current/public;
13
+
14
+ index index.php index.html index.htm;
15
+
16
+ access_log /data/logs/nginx/<%= fetch(:application) %>.log customized_<%= fetch(:application) %>;
17
+ error_log /data/logs/nginx/<%= fetch(:application) %>.error.log warn;
18
+
19
+ # 修改为 Laravel 转发规则
20
+ location / {
21
+ try_files $uri $uri/ /index.php?$query_string;
22
+ }
23
+
24
+ # PHP 支持
25
+ location ~ \.php$ {
26
+ try_files $uri /index.php =404;
27
+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
28
+ fastcgi_pass <%= fetch(:bind) %>;
29
+ fastcgi_index index.php;
30
+ include fastcgi.conf;
31
+
32
+ #fastcgi_intercept_errors on;
33
+ }
34
+
35
+ location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
36
+ expires 30d;
37
+ access_log off;
38
+ log_not_found off;
39
+ }
40
+
41
+ location ~ .*\.(js|css)?$ {
42
+ expires 7d;
43
+ access_log off;
44
+ }
45
+
46
+ location = /favicon.ico { access_log off; log_not_found off; }
47
+ location = /robots.txt { access_log off; log_not_found off; }
48
+ location = /download.html { access_log off; log_not_found off; }
49
+
50
+ # error_page 500 502 503 504 /50x.html;
51
+ }
@@ -0,0 +1,38 @@
1
+ set :stage, :<%= entry[:stage] %>
2
+ set :branch, ENV['BRANCH'] || 'master'
3
+
4
+ # used in case we're deploying multiple versions of the same
5
+ # app side by side. Also provides quick sanity checks when looking
6
+ # at filepaths
7
+ set :full_app_name, "#{fetch(:application)}_#{fetch(:stage)}"
8
+
9
+ set :deploy_to, "/data/projects/#{fetch(:application)}"
10
+ set :enable_ssl, false
11
+
12
+ # server-based syntax
13
+ # ======================
14
+ # Defines a single server with a list of roles and multiple properties.
15
+ # You can define all roles on a single server, or split them:
16
+
17
+ # server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
18
+ # server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
19
+ # server 'db.example.com', user: 'deploy', roles: %w{db}
20
+
21
+ # setup_config options
22
+ # ======================
23
+ # Server name use for nginx, default: localhost
24
+ # set :server_name, 'localhost'
25
+
26
+ # Which user to run nginx, default: nginx
27
+ # set :nginx_user, 'nginx'
28
+
29
+ # Bind for php-fpm, default: unix:/run/php/#{fetch(:php_fpm)}.sock
30
+ # set :bind, '127.0.0.1:8080'
31
+
32
+ # Where to set fpm pool config, default: nil
33
+ # if nil or empty, fpm_pool config will not be set up automatically
34
+ # set :fpm_pool_path, ''
35
+
36
+ # Where to set nginx server config, default: nil
37
+ # if nil or empty, nginx_server config will not be set up automatically
38
+ # set :nginx_server_path, ''
File without changes
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-laravel-lazy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Ivan Chou
8
+ - Peter Mitchell
9
+ - Andrew Miller
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-08-18 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '3.0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: capistrano-composer
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: 0.0.6
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: 0.0.6
43
+ - !ruby/object:Gem::Dependency
44
+ name: capistrano-file-permissions
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.0'
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: bundler
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.3'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '1.3'
71
+ - !ruby/object:Gem::Dependency
72
+ name: rake
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '10.4'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '10.4'
85
+ description: Laravel specific deployment options for Capistrano 3.x
86
+ email:
87
+ - yiichou@gmail.com
88
+ - peterjmit@gmail.com
89
+ - ikari7789@yahoo.com
90
+ executables:
91
+ - cap_laravel
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".gitignore"
96
+ - Gemfile
97
+ - LICENSE
98
+ - README.md
99
+ - Rakefile
100
+ - bin/cap_laravel
101
+ - capistrano-laravel.gemspec
102
+ - lib/capistrano-laravel.rb
103
+ - lib/capistrano/laravel.rb
104
+ - lib/capistrano/laravel/helpers.rb
105
+ - lib/capistrano/laravel/version.rb
106
+ - lib/capistrano/tasks/laravel.rake
107
+ - lib/capistrano/tasks/php_fpm.rake
108
+ - lib/capistrano/tasks/setup_config.rake
109
+ - lib/capistrano/templates/Capfile
110
+ - lib/capistrano/templates/deploy.rb.erb
111
+ - lib/capistrano/templates/fpm.conf.erb
112
+ - lib/capistrano/templates/nginx.conf.erb
113
+ - lib/capistrano/templates/stage.rb.erb
114
+ homepage: https://github.com/IvanChou/laravel/tree/lazy
115
+ licenses:
116
+ - MIT
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.5.1
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Laravel deployment for Capistrano 3.x
138
+ test_files: []