california 0.4.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.md +3 -1
- data/README.md +23 -7
- data/lib/california/capistrano/tasks/deploy.rake +30 -16
- data/lib/california/stage.rb +2 -2
- data/lib/california/templates/app/config/deploy/stage.rb +21 -8
- data/lib/california/version.rb +1 -1
- metadata +12 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8bfdd67a9f3ee5fdd0b596fd1167067e0077a5ac
|
|
4
|
+
data.tar.gz: 2222a88579562b1b19b3c6198129ad22ce21e8f4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8b7a2a7ff7f4271948d4233bec61225651493c33e66267669c9ee83d02667085309536ecfcf5fa1214a109b8c4d39353ea8b64e7ad4dc2c1417ec78cc3dab214
|
|
7
|
+
data.tar.gz: 42ce9ca509167b5cd4c0f1a98a337d3341a217cab2d840ae4ab903ed70d9618babef041e5f5337f88a7cd3991f233fe15798dfa9ca13fb53e763f5f8bdf4efa9
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
## Opinionated
|
|
1
|
+
## Opinionated Capistrano deployment for dummies
|
|
2
2
|
|
|
3
|
+
[](https://rubygems.org/gems/california)
|
|
3
4
|
[](https://travis-ci.org/halo/california)
|
|
4
5
|
|
|
6
|
+
When using [Capistrano](https://github.com/capistrano/capistrano) to deploy an application to a server, it runs [all this stuff](https://github.com/capistrano/capistrano/blob/master/lib/capistrano/tasks/deploy.rake) creating a new symlink for every release, cleans up old ones, etc..
|
|
7
|
+
|
|
8
|
+
California is an opinionated out-of-the-box, best-practice configuration that aims to make things a little bit simpler for both beginners and advanced users.
|
|
9
|
+
|
|
10
|
+
### Design Goals
|
|
11
|
+
|
|
12
|
+
* Don't separate releases in different directories. Just [perform a simple checkout](https://github.com/halo/california/blob/master/lib/california/capistrano/tasks/deploy.rake#L21-L24) that updates the code in place.
|
|
13
|
+
|
|
14
|
+
* Introduce convention over configuration, e.g. as to [where the applications are deployed](https://github.com/halo/california/blob/master/lib/california/stage.rb#L40-L42).
|
|
15
|
+
|
|
16
|
+
* Every app has its own user on the server and when running commands during deploy, [load the `.bash_profile` of that user](https://github.com/halo/california/blob/master/lib/california/stage.rb#L65-L67)
|
|
17
|
+
|
|
18
|
+
* Nicer logging output so that you *really* know at which stage of the deploy you are (update code, run bundler, restart)
|
|
19
|
+
|
|
5
20
|
### Requirements
|
|
6
21
|
|
|
7
22
|
* Ruby >= 2.0
|
|
@@ -15,7 +30,7 @@ Create a new repository with a Gemfile like this and run `bundle install` to get
|
|
|
15
30
|
# Content of Gemfile
|
|
16
31
|
source 'https://rubygems.org'
|
|
17
32
|
|
|
18
|
-
gem 'california'
|
|
33
|
+
gem 'california'
|
|
19
34
|
```
|
|
20
35
|
|
|
21
36
|
Then run the generator for creating your first app you may want to deploy.
|
|
@@ -26,17 +41,18 @@ Let's say the name of the app is "hello_world".
|
|
|
26
41
|
bundle exec california generate hello_world
|
|
27
42
|
```
|
|
28
43
|
|
|
29
|
-
|
|
44
|
+
Follow the instructions in `hello_world/deploy/production.rb` (or whichever stages you have) and define which servers you want to deploy to.
|
|
30
45
|
|
|
31
46
|
### Server preparation
|
|
32
47
|
|
|
33
|
-
When deploying your `hello_world` app, it is assumed that you can ssh into the server with the
|
|
48
|
+
When deploying your `hello_world` app, it is assumed that you can ssh into the server with the username `hello_world` and that the repository has been cloned to `/mnt/apps/hello_world/repository`.
|
|
49
|
+
|
|
50
|
+
The reason for this directory is that if you are on AWS, `/mnt` is the default path for permanent storage. If you're not on AWS, you may just ride along and follow the convention.
|
|
34
51
|
|
|
35
|
-
|
|
52
|
+
If you configure your application via environment variables, you can add them in a file called `/mnt/envs/hello_world`.
|
|
36
53
|
|
|
37
54
|
```bash
|
|
38
55
|
# Example of content of /mnt/envs/hello_world
|
|
39
|
-
SECRET_TOKEN="abcdef"
|
|
40
56
|
DATABASE_URL="postgres://db.example.com"
|
|
41
57
|
```
|
|
42
58
|
|
|
@@ -54,4 +70,4 @@ bundle exec cap production deploy migrate=true
|
|
|
54
70
|
|
|
55
71
|
### Copyright
|
|
56
72
|
|
|
57
|
-
MIT
|
|
73
|
+
MIT 2018 halo. See [LICENSE.md](http://github.com/halo/california/blob/master/LICENSE.md).
|
|
@@ -57,15 +57,19 @@ namespace :deploy do
|
|
|
57
57
|
# –––––––––––––––
|
|
58
58
|
|
|
59
59
|
task :updated do
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
if fetch(:skip_bundler)
|
|
61
|
+
logger.info 'Skipping Bundler...'
|
|
62
|
+
else
|
|
63
|
+
logger.info 'Running Bundler...'
|
|
64
|
+
|
|
65
|
+
on roles :app do
|
|
66
|
+
as fetch(:application) do
|
|
67
|
+
within fetch(:deploy_to) do
|
|
68
|
+
|
|
69
|
+
# Running Bundler.
|
|
70
|
+
core_count = capture(:nproc).chomp
|
|
71
|
+
execute :bundle, :install, '--deployment', '--quiet', '--without', 'development', 'test', '--jobs', core_count
|
|
72
|
+
end
|
|
69
73
|
end
|
|
70
74
|
end
|
|
71
75
|
end
|
|
@@ -76,13 +80,23 @@ namespace :deploy do
|
|
|
76
80
|
# ––––––––––––––––––
|
|
77
81
|
|
|
78
82
|
task :publishing do
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
if fetch(:skip_restart)
|
|
84
|
+
logger.info 'Skipping Restart...'
|
|
85
|
+
else
|
|
86
|
+
|
|
87
|
+
on roles :app do
|
|
88
|
+
as fetch(:application) do
|
|
89
|
+
|
|
90
|
+
if fetch(:restart_strategy) == 'restart.txt'
|
|
91
|
+
logger.info 'Restarting the app via restart.txt...'
|
|
92
|
+
within File.join(fetch(:deploy_to), 'tmp') do
|
|
93
|
+
execute :touch, 'restart.txt'
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
else
|
|
97
|
+
logger.info 'Restarting the app via passenger-config...'
|
|
98
|
+
execute 'passenger-config', 'restart-app', fetch(:deploy_to)
|
|
99
|
+
end
|
|
86
100
|
end
|
|
87
101
|
end
|
|
88
102
|
end
|
data/lib/california/stage.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module
|
|
1
|
+
module CaliforniaLogger
|
|
2
2
|
def self.logger
|
|
3
3
|
@logger ||= logger!
|
|
4
4
|
end
|
|
@@ -15,7 +15,7 @@ module BenderLogger
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def logger
|
|
18
|
-
|
|
18
|
+
CaliforniaLogger.logger
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
# Rails environment sanity check.
|
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
# First we need to set a stage name.
|
|
2
|
+
# This is usually an environment such as `production`, `staging`, or `test`.
|
|
3
|
+
# By default, the stage name is derived from the filename of THIS file.
|
|
3
4
|
set :stage, File.basename(__FILE__, '.rb')
|
|
4
5
|
|
|
5
|
-
#
|
|
6
|
-
|
|
6
|
+
# By default, we will run `bundle install`, to skip that, uncomment the following line.
|
|
7
|
+
# This is useful for non-ruby applications.
|
|
8
|
+
# set :skip_bundler, true
|
|
7
9
|
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
10
|
+
# By default the webserver is restarted using `/usr/bin/passenger-config`.
|
|
11
|
+
# If you prefer the old-fashioned `touch tmp/restart.txt` uncomment the following line.
|
|
12
|
+
# set :restart_strategy, 'restart.txt'
|
|
11
13
|
|
|
12
|
-
# You
|
|
14
|
+
# You can skip the restart alltogether by uncommenting the following line.
|
|
15
|
+
# set :skip_restart, true
|
|
16
|
+
|
|
17
|
+
# You may also set any custom Capistrano options if you wish:
|
|
13
18
|
# set :ssh_options, {
|
|
14
19
|
# forward_agent: true,
|
|
15
20
|
# port: 12345,
|
|
16
21
|
# keys: Pathname.new('~/.ssh/mykey').expand_path.to_s,
|
|
17
22
|
# }
|
|
23
|
+
|
|
24
|
+
# That's all for custom configuration. Now we can load the default configuration.
|
|
25
|
+
load 'california/stage'
|
|
26
|
+
|
|
27
|
+
# Important: Now you need to define AT LEAST ONE server.
|
|
28
|
+
|
|
29
|
+
# Example: The one with the role "migrator" will be entitled to run migrations:
|
|
30
|
+
# server '203.0.113.19', roles: %w{ all app web_server migrator }
|
data/lib/california/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: california
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- halo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-07-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: capistrano
|
|
@@ -16,30 +16,30 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '3.
|
|
19
|
+
version: '3.11'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '3.
|
|
26
|
+
version: '3.11'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: thor
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0.
|
|
33
|
+
version: '0.20'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0.
|
|
40
|
+
version: '0.20'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: rspec
|
|
42
|
+
name: guard-rspec
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
45
|
- - ">="
|
|
@@ -53,7 +53,7 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: rb-fsevent
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
@@ -67,7 +67,7 @@ dependencies:
|
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
|
-
name:
|
|
70
|
+
name: rspec
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - ">="
|
|
@@ -115,7 +115,8 @@ files:
|
|
|
115
115
|
- lib/california/templates/app/config/deploy/stage.rb
|
|
116
116
|
- lib/california/version.rb
|
|
117
117
|
homepage: https://github.com/halo/california
|
|
118
|
-
licenses:
|
|
118
|
+
licenses:
|
|
119
|
+
- MIT
|
|
119
120
|
metadata: {}
|
|
120
121
|
post_install_message:
|
|
121
122
|
rdoc_options: []
|
|
@@ -133,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
133
134
|
version: '0'
|
|
134
135
|
requirements: []
|
|
135
136
|
rubyforge_project:
|
|
136
|
-
rubygems_version: 2.
|
|
137
|
+
rubygems_version: 2.6.11
|
|
137
138
|
signing_key:
|
|
138
139
|
specification_version: 4
|
|
139
140
|
summary: Capistrano 3 for dummies.
|