capistrano-play 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +202 -0
- data/README.md +63 -0
- data/Rakefile +1 -0
- data/capistrano-play.gemspec +19 -0
- data/lib/capistrano-play.rb +8 -0
- data/lib/capistrano-play/deploy.rb +438 -0
- data/lib/capistrano-play/templates/ivysettings.erb +2 -0
- data/lib/capistrano-play/templates/upstart.erb +9 -0
- data/lib/capistrano-play/version.rb +5 -0
- metadata +72 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# capistrano-play
|
2
|
+
|
3
|
+
a capistrano recipe to deploy [Play!](http://www.playframework.org/) apps.
|
4
|
+
|
5
|
+
this project was forked from [play-capistrano](https://github.com/mandubian/play-capistrano) and modified to create gem.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'capistrano-play'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install capistrano-play
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
This recipes will try to do following things during Capistrano `deploy:setup` and `deploy` tasks.
|
24
|
+
|
25
|
+
1. Download and install Play! runtime for current project
|
26
|
+
2. Prepare `~/.ivy2/ivysettings.xml` (optional)
|
27
|
+
3. Build Play! project remotely (default) or locally
|
28
|
+
|
29
|
+
To build you Play! projects during Capistrano `deploy` tasks, add following in you `config/deploy.rb`. By default, Play! precompile will run after the Capistrano's `deploy:finalize_update`.
|
30
|
+
|
31
|
+
# in "config/deploy.rb"
|
32
|
+
require 'capistrano-play'
|
33
|
+
set(:play_version, '1.2.4') # Play! version for your app
|
34
|
+
|
35
|
+
Following options are available to manage your Play! build.
|
36
|
+
|
37
|
+
* `:play_version` - Play! version for your app. `1.2.5` by default.
|
38
|
+
* `:play_zip_url` - download URL of Play! runtime.
|
39
|
+
* `:play_preserve_zip` - controls whether preserving downloaded archive or not. `true` by default.
|
40
|
+
* `:play_daemonize_method` - `:play` or `:upstart` are sensible.
|
41
|
+
* `:play_use_precompile` - performe precompilation before restarting service. `true` by default.
|
42
|
+
* `:play_precompile_locally` - perform precompilation on localhost. `false` by default.
|
43
|
+
* `:play_java_home` - `JAVA_HOME` for Play! runtime.
|
44
|
+
* `:play_java_home_local` - `JAVA_HOME` for Play! runtime on localhost.
|
45
|
+
* `:play_setup_ivy` - controls whether managing `~/.ivy2/ivysettings.xml` or not. `false` by default.
|
46
|
+
* `:play_setup_ivy_locally` - controls whether managing `~/.ivy2/ivysettings.xml` or not. `false` by default.
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
55
|
+
|
56
|
+
## Author
|
57
|
+
|
58
|
+
- YAMASHITA Yuu (https://github.com/yyuu)
|
59
|
+
- Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
Apache License 2.0
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/capistrano-play/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Yamashita Yuu"]
|
6
|
+
gem.email = ["yamashita@geishatokyo.com"]
|
7
|
+
gem.description = %q{a capistrano recipe to deploy Play! apps.}
|
8
|
+
gem.summary = %q{a capistrano recipe to deploy Play! apps.}
|
9
|
+
gem.homepage = "https://github.com/yyuu/capistrano-play"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "capistrano-play"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Capistrano::Play::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency("capistrano")
|
19
|
+
end
|
@@ -0,0 +1,438 @@
|
|
1
|
+
# Copyright 2011 Pascal Voitot [@mandubian][pascal.voitot.dev@gmail.com]
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at:
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
#
|
14
|
+
|
15
|
+
# if you're still using the script/reaper helper you will need
|
16
|
+
# these http://github.com/rails/irs_process_scripts
|
17
|
+
|
18
|
+
# If you are using Passenger mod_rails uncomment this:
|
19
|
+
# namespace :deploy do
|
20
|
+
# task :start do ; end
|
21
|
+
# task :stop do ; end
|
22
|
+
# task :restart, :roles => :app, :except => { :no_release => true } do
|
23
|
+
# run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
require 'erb'
|
28
|
+
|
29
|
+
module Capistrano
|
30
|
+
module Play
|
31
|
+
def self.extended(configuration)
|
32
|
+
configuration.load {
|
33
|
+
# without this, there are problems with sudo on remote server
|
34
|
+
default_run_options[:pty] = true
|
35
|
+
|
36
|
+
namespace :deploy do
|
37
|
+
task :start, :roles => :app, :except => { :no_release => true } do
|
38
|
+
play.start
|
39
|
+
end
|
40
|
+
|
41
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
42
|
+
play.restart
|
43
|
+
end
|
44
|
+
|
45
|
+
task :stop, :roles => :app, :except => { :no_release => true } do
|
46
|
+
play.stop
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
after 'deploy:setup', 'play:setup'
|
51
|
+
after 'deploy:finalize_update', 'play:update'
|
52
|
+
|
53
|
+
namespace :play do
|
54
|
+
_cset :play_version, '1.2.5'
|
55
|
+
_cset :play_major_version do
|
56
|
+
play_version.scan(/\d+/).first.to_i
|
57
|
+
end
|
58
|
+
_cset :play_zip_url do
|
59
|
+
"http://download.playframework.org/releases/#{File.basename(play_zip_file)}"
|
60
|
+
end
|
61
|
+
_cset :play_preserve_zip, true
|
62
|
+
_cset :play_zip_file do
|
63
|
+
File.join(shared_path, 'tools', 'play', "play-#{play_version}.zip")
|
64
|
+
end
|
65
|
+
_cset :play_path do
|
66
|
+
File.join(shared_path, 'tools', 'play', "play-#{play_version}")
|
67
|
+
end
|
68
|
+
_cset :play_bin do
|
69
|
+
File.join(play_path, 'play')
|
70
|
+
end
|
71
|
+
_cset :play_cmd do
|
72
|
+
if fetch(:play_java_home, nil)
|
73
|
+
"env JAVA_HOME=#{play_java_home} #{play_bin}"
|
74
|
+
else
|
75
|
+
play_bin
|
76
|
+
end
|
77
|
+
end
|
78
|
+
_cset :play_daemonize_method, :play
|
79
|
+
_cset :play_daemon do
|
80
|
+
daemonize.__send__(play_daemonize_method)
|
81
|
+
end
|
82
|
+
_cset :play_pid_file do
|
83
|
+
fetch(:app_pid, File.join(shared_path, 'pids', 'server.pid')) # for backward compatibility
|
84
|
+
end
|
85
|
+
_cset :play_use_precompile, true # performe precompilation before restarting service if true
|
86
|
+
|
87
|
+
_cset :play_zip_file_local do
|
88
|
+
File.join(File.expand_path('.'), 'tools', 'play', "play-#{play_version}.zip")
|
89
|
+
end
|
90
|
+
_cset :play_path_local do
|
91
|
+
File.join(File.expand_path('.'), 'tools', 'play', "play-#{play_version}")
|
92
|
+
end
|
93
|
+
_cset :play_bin_local do
|
94
|
+
File.join(play_path_local, 'play')
|
95
|
+
end
|
96
|
+
_cset :play_cmd_local do
|
97
|
+
if fetch(:play_java_home_local, nil)
|
98
|
+
"env JAVA_HOME=#{play_java_home_local} #{play_bin_local}"
|
99
|
+
else
|
100
|
+
play_bin_local
|
101
|
+
end
|
102
|
+
end
|
103
|
+
_cset :play_project_path do
|
104
|
+
release_path
|
105
|
+
end
|
106
|
+
_cset :play_project_path_local do
|
107
|
+
File.expand_path('.')
|
108
|
+
end
|
109
|
+
_cset :play_target_path do
|
110
|
+
if play_major_version < 2
|
111
|
+
File.join(play_project_path, 'precompiled')
|
112
|
+
else
|
113
|
+
File.join(play_project_path, 'target')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
_cset :play_target_path_local do
|
117
|
+
if play_major_version < 2
|
118
|
+
File.join(play_project_path_local, 'precompiled')
|
119
|
+
else
|
120
|
+
File.join(play_project_path_local, 'target')
|
121
|
+
end
|
122
|
+
end
|
123
|
+
_cset :play_dependencies_path_map do
|
124
|
+
if play_major_version < 2
|
125
|
+
{
|
126
|
+
File.join(play_project_path, 'lib') => File.join(play_project_path_local, 'lib'),
|
127
|
+
File.join(play_project_path, 'modules') => File.join(play_project_path_local, 'modules'),
|
128
|
+
}
|
129
|
+
else
|
130
|
+
{
|
131
|
+
play_target_path => play_target_path_local,
|
132
|
+
}
|
133
|
+
end
|
134
|
+
end
|
135
|
+
_cset :play_subcmd_dependencies do
|
136
|
+
if play_major_version < 2
|
137
|
+
"dependencies --forProd --sync"
|
138
|
+
else
|
139
|
+
"dependencies"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
_cset :play_subcmd_precompile do
|
143
|
+
if play_major_version < 2
|
144
|
+
"precompile"
|
145
|
+
else
|
146
|
+
"compile"
|
147
|
+
end
|
148
|
+
end
|
149
|
+
_cset :play_precompile_locally, false # perform precompilation on localhost
|
150
|
+
|
151
|
+
desc "install play if needed"
|
152
|
+
task :setup do
|
153
|
+
transaction {
|
154
|
+
setup_ivy if fetch(:play_setup_ivy, false)
|
155
|
+
install
|
156
|
+
setup_locally if play_precompile_locally
|
157
|
+
}
|
158
|
+
transaction {
|
159
|
+
play_daemon.setup
|
160
|
+
}
|
161
|
+
end
|
162
|
+
|
163
|
+
task :setup_locally do
|
164
|
+
transaction {
|
165
|
+
setup_ivy_locally if fetch(:play_setup_ivy_locally, false)
|
166
|
+
install_locally
|
167
|
+
}
|
168
|
+
end
|
169
|
+
|
170
|
+
_cset :play_ivy_settings_template, File.join(File.dirname(__FILE__), 'templates', 'ivysettings.erb')
|
171
|
+
_cset :play_ivy_settings do
|
172
|
+
File.join(capture('echo $HOME').chomp, '.ivy2', 'ivysettings.xml')
|
173
|
+
end
|
174
|
+
task :setup_ivy, :roles => :app, :except => { :no_release => true } do
|
175
|
+
tempfile = File.join('/tmp', File.basename(play_ivy_settings))
|
176
|
+
on_rollback {
|
177
|
+
run "rm -f #{tempfile}"
|
178
|
+
}
|
179
|
+
template = File.read(play_ivy_settings_template)
|
180
|
+
result = ERB.new(template).result(binding)
|
181
|
+
run(<<-EOS)
|
182
|
+
( test -d #{File.dirname(play_ivy_settings)} || mkdir -p #{File.dirname(play_ivy_settings)} ) &&
|
183
|
+
( test -f #{play_ivy_settings} && mv -f #{play_ivy_settings} #{play_ivy_settings}.orig; true );
|
184
|
+
EOS
|
185
|
+
put result, tempfile
|
186
|
+
run "diff #{play_ivy_settings} #{tempfile} || mv -f #{tempfile} #{play_ivy_settings}"
|
187
|
+
end
|
188
|
+
|
189
|
+
_cset :play_ivy_settings_local, File.join(ENV['HOME'], '.ivy2', 'ivysettings.xml')
|
190
|
+
task :setup_ivy_locally, :except => { :no_release => true } do
|
191
|
+
template = File.read(play_ivy_settings_template)
|
192
|
+
result = ERB.new(template).result(binding)
|
193
|
+
run_locally(<<-EOS)
|
194
|
+
( test -d #{File.dirname(play_ivy_settings_local)} || mkdir -p #{File.dirname(play_ivy_settings_local)} ) &&
|
195
|
+
( test -f #{play_ivy_settings_local} && mv -f #{play_ivy_settings_local} #{play_ivy_settings_local}.orig; true );
|
196
|
+
EOS
|
197
|
+
File.open(play_ivy_settings_local, 'w') { |fp| fp.write(result) }
|
198
|
+
end
|
199
|
+
|
200
|
+
task :install, :roles => :app, :except => { :no_release => true } do
|
201
|
+
temp_zip = File.join('/tmp', File.basename(play_zip_file))
|
202
|
+
temp_dir = File.join('/tmp', File.basename(play_zip_file, '.zip'))
|
203
|
+
on_rollback {
|
204
|
+
files = [ play_path, temp_zip, temp_dir ]
|
205
|
+
files << play_zip_file unless play_preserve_zip
|
206
|
+
run "#{try_sudo} rm -rf #{files.join(' ')}"
|
207
|
+
}
|
208
|
+
run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip
|
209
|
+
|
210
|
+
dirs = [ File.dirname(play_zip_file), File.dirname(play_path) ].uniq()
|
211
|
+
run(<<-EOS)
|
212
|
+
if ! test -x #{play_bin}; then
|
213
|
+
mkdir -p #{dirs.join(' ')} &&
|
214
|
+
( test -f #{play_zip_file} || ( wget --no-verbose -O #{temp_zip} #{play_zip_url} && #{try_sudo} mv -f #{temp_zip} #{play_zip_file}; true ) ) &&
|
215
|
+
( test -d #{play_path} || ( unzip -q #{play_zip_file} -d #{File.dirname(temp_dir)} && #{try_sudo} mv -f #{temp_dir} #{play_path}; true ) ) &&
|
216
|
+
test -x #{play_bin};
|
217
|
+
fi;
|
218
|
+
EOS
|
219
|
+
run "#{try_sudo} rm -f #{play_zip_file}" unless play_preserve_zip
|
220
|
+
end
|
221
|
+
|
222
|
+
task :install_locally, :except => { :no_release => true } do
|
223
|
+
on_rollback {
|
224
|
+
files = [ play_path_local, play_zip_file_local ]
|
225
|
+
run_locally("rm -rf #{files.join(' ')}")
|
226
|
+
}
|
227
|
+
dirs = [ File.dirname(play_zip_file_local), File.dirname(play_path_local) ].uniq()
|
228
|
+
run_locally(<<-EOS)
|
229
|
+
if ! test -x #{play_bin_local}; then
|
230
|
+
mkdir -p #{dirs.join(' ')} &&
|
231
|
+
( test -f #{play_zip_file_local} || ( wget --no-verbose -O #{play_zip_file_local} #{play_zip_url} ) ) &&
|
232
|
+
( test -d #{play_path_local} || unzip -q #{play_zip_file_local} -d #{File.dirname(play_path_local)} ) &&
|
233
|
+
test -x #{play_bin_local};
|
234
|
+
fi;
|
235
|
+
EOS
|
236
|
+
end
|
237
|
+
|
238
|
+
namespace :daemonize do
|
239
|
+
namespace :play do
|
240
|
+
task :setup, :roles => :app, :except => { :no_release => true } do
|
241
|
+
# nop
|
242
|
+
end
|
243
|
+
|
244
|
+
_cset :play_start_options do
|
245
|
+
options = []
|
246
|
+
options << "-Xss2048k"
|
247
|
+
options << "--%prod"
|
248
|
+
options
|
249
|
+
end
|
250
|
+
task :start, :roles => :app, :except => { :no_release => true } do
|
251
|
+
run "rm -f #{play_pid_file}" # FIXME: should check if the pid is active
|
252
|
+
play_start_options << "-Dprecompiled=true" if play_use_precompile
|
253
|
+
run "cd #{play_project_path} && nohup #{play_cmd} start --pid_file=#{play_pid_file} #{play_start_options.join(' ')}"
|
254
|
+
end
|
255
|
+
|
256
|
+
task :stop, :roles => :app, :except => { :no_release => true } do
|
257
|
+
run "cd #{play_project_path} && #{play_cmd} stop --pid_file=#{play_pid_file}"
|
258
|
+
end
|
259
|
+
|
260
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
261
|
+
stop
|
262
|
+
start
|
263
|
+
end
|
264
|
+
|
265
|
+
task :status, :roles => :app, :except => { :no_release => true } do
|
266
|
+
run "cd #{play_project_path} && #{play_cmd} status --pid_file=#{play_pid_file}"
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
namespace :upstart do
|
271
|
+
_cset :play_upstart_service do
|
272
|
+
application
|
273
|
+
end
|
274
|
+
_cset :play_upstart_config do
|
275
|
+
File.join('/etc', 'init', "#{play_upstart_service}.conf")
|
276
|
+
end
|
277
|
+
_cset :play_upstart_config_template, File.join(File.dirname(__FILE__), 'templates', 'upstart.erb')
|
278
|
+
_cset :play_upstart_options do
|
279
|
+
options = []
|
280
|
+
options << "-Xss2048k"
|
281
|
+
options << "--%prod"
|
282
|
+
options
|
283
|
+
end
|
284
|
+
_cset :play_upstart_runner do
|
285
|
+
user
|
286
|
+
end
|
287
|
+
|
288
|
+
task :setup, :roles => :app, :except => { :no_release => true } do
|
289
|
+
tempfile = File.join('/tmp', File.basename(play_upstart_config))
|
290
|
+
on_rollback {
|
291
|
+
run "rm -f #{tempfile}"
|
292
|
+
}
|
293
|
+
play_upstart_options << "-Dprecompiled=true" if play_use_precompile
|
294
|
+
template = File.read(play_upstart_config_template)
|
295
|
+
result = ERB.new(template).result(binding)
|
296
|
+
put result, tempfile
|
297
|
+
run "diff #{play_upstart_config} #{tempfile} || #{sudo} mv -f #{tempfile} #{play_upstart_config}"
|
298
|
+
end
|
299
|
+
|
300
|
+
task :start, :roles => :app, :except => { :no_release => true } do
|
301
|
+
run "#{sudo} service #{play_upstart_service} start"
|
302
|
+
end
|
303
|
+
|
304
|
+
task :stop, :roles => :app, :except => { :no_release => true } do
|
305
|
+
run "#{sudo} service #{play_upstart_service} stop"
|
306
|
+
end
|
307
|
+
|
308
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
309
|
+
run "#{sudo} service #{play_upstart_service} restart || #{sudo} service #{play_upstart_service} start"
|
310
|
+
end
|
311
|
+
|
312
|
+
task :status, :roles => :app, :except => { :no_release => true } do
|
313
|
+
run "#{sudo} service #{play_upstart_service} status"
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
desc "update play runtime environment"
|
319
|
+
task :update, :roles => :app, :except => { :no_release => true } do
|
320
|
+
if play_major_version < 2
|
321
|
+
# FIXME: made tmp/ group writable since deploy:finalize_update creates non-group-writable tmp/
|
322
|
+
run "#{try_sudo} chmod g+w #{play_project_path}/tmp" if fetch(:group_writable, true)
|
323
|
+
end
|
324
|
+
|
325
|
+
if play_use_precompile
|
326
|
+
if play_precompile_locally
|
327
|
+
setup_locally
|
328
|
+
transaction {
|
329
|
+
dependencies_locally
|
330
|
+
precompile_locally
|
331
|
+
upload_locally
|
332
|
+
}
|
333
|
+
else
|
334
|
+
dependencies
|
335
|
+
precompile
|
336
|
+
end
|
337
|
+
else
|
338
|
+
dependencies
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
task :dependencies, :roles => :app, :except => { :no_release => true } do
|
343
|
+
run "cd #{play_project_path} && #{play_cmd} #{play_subcmd_dependencies}"
|
344
|
+
end
|
345
|
+
|
346
|
+
task :dependencies_locally, :roles => :app, :except => { :no_release => true } do
|
347
|
+
if dry_run
|
348
|
+
logger.info("resolving play dependencies locally: #{play_project_path_local}")
|
349
|
+
else
|
350
|
+
abort("error on resolving play dependencies.") unless system("cd #{play_project_path_local} && #{play_cmd_local} #{play_subcmd_dependencies}")
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
task :precompile, :roles => :app, :except => { :no_release => true } do
|
355
|
+
run "cd #{play_project_path} && #{play_cmd} #{play_subcmd_precompile}"
|
356
|
+
end
|
357
|
+
|
358
|
+
task :precompile_locally, :roles => :app, :except => { :no_release => true } do
|
359
|
+
on_rollback {
|
360
|
+
run_locally("cd #{play_project_path_local} && #{play_cmd_local} clean")
|
361
|
+
}
|
362
|
+
if dry_run
|
363
|
+
logger.info("compiling play application locally: #{play_project_path_local}")
|
364
|
+
else
|
365
|
+
abort("error on resolving play dependencies.") unless system("cd #{play_project_path_local} && #{play_cmd_local} #{play_subcmd_precompile}")
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
task :upload_locally, :roles => :app, :except => { :no_release => true } do
|
370
|
+
map = play_dependencies_path_map.merge(play_target_path => play_target_path_local)
|
371
|
+
run "mkdir -p #{map.keys.join(' ')}"
|
372
|
+
map.map { |dst, src|
|
373
|
+
run_locally "cd #{File.dirname(src)} && tar chzf #{src}.tar.gz #{File.basename(src)}" unless dry_run
|
374
|
+
upload "#{src}.tar.gz", "#{dst}.tar.gz"
|
375
|
+
run "cd #{File.dirname(dst)} && tar xzf #{dst}.tar.gz && rm #{dst}.tar.gz"
|
376
|
+
}
|
377
|
+
run "chmod -R g+w #{map.keys.join(' ')}" if fetch(:group_writable, true)
|
378
|
+
end
|
379
|
+
|
380
|
+
desc "start play service"
|
381
|
+
task :start, :roles => :app, :except => { :no_release => true } do
|
382
|
+
play_daemon.start
|
383
|
+
end
|
384
|
+
|
385
|
+
desc "stop play service"
|
386
|
+
task :stop, :roles => :app, :except => { :no_release => true } do
|
387
|
+
play_daemon.stop
|
388
|
+
end
|
389
|
+
|
390
|
+
desc "restart play service"
|
391
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
392
|
+
play_daemon.restart
|
393
|
+
end
|
394
|
+
|
395
|
+
desc "view play status"
|
396
|
+
task :status, :roles => :app, :except => { :no_release => true } do
|
397
|
+
play_daemon.status
|
398
|
+
end
|
399
|
+
|
400
|
+
desc "view play pid"
|
401
|
+
task :pid, :roles => :app, :except => { :no_release => true } do
|
402
|
+
run "cd #{play_project_path} && #{play_cmd} pid --pid_file=#{play_pid_file}"
|
403
|
+
end
|
404
|
+
|
405
|
+
desc "view play version"
|
406
|
+
task :version, :roles => :app, :except => { :no_release => true } do
|
407
|
+
run "cd #{play_project_path} && #{play_cmd} version --pid_file=#{play_pid_file}"
|
408
|
+
end
|
409
|
+
|
410
|
+
desc "view running play apps"
|
411
|
+
task :ps, :roles => :app, :except => { :no_release => true } do
|
412
|
+
run "ps -eaf | grep 'play'"
|
413
|
+
end
|
414
|
+
|
415
|
+
desc "kill play processes"
|
416
|
+
task :kill, :roles => :app, :except => { :no_release => true } do
|
417
|
+
run "ps -ef | grep 'play' | grep -v 'grep' | awk '{print $2}'| xargs -i kill {} ; echo ''"
|
418
|
+
end
|
419
|
+
|
420
|
+
desc "view logfiles"
|
421
|
+
task :logs, :roles => :app, :except => { :no_release => true } do
|
422
|
+
run "tail -f #{shared_path}/log/#{application}.log" do |channel, stream, data|
|
423
|
+
puts # for an extra line break before the host name
|
424
|
+
puts "#{channel[:host]}: #{data}"
|
425
|
+
break if stream == :err
|
426
|
+
end
|
427
|
+
end
|
428
|
+
end
|
429
|
+
}
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|
433
|
+
|
434
|
+
if Capistrano::Configuration.instance
|
435
|
+
Capistrano::Configuration.instance.extend(Capistrano::Play)
|
436
|
+
end
|
437
|
+
|
438
|
+
# vim:set ft=ruby :
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-play
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yamashita Yuu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: a capistrano recipe to deploy Play! apps.
|
31
|
+
email:
|
32
|
+
- yamashita@geishatokyo.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- capistrano-play.gemspec
|
43
|
+
- lib/capistrano-play.rb
|
44
|
+
- lib/capistrano-play/deploy.rb
|
45
|
+
- lib/capistrano-play/templates/ivysettings.erb
|
46
|
+
- lib/capistrano-play/templates/upstart.erb
|
47
|
+
- lib/capistrano-play/version.rb
|
48
|
+
homepage: https://github.com/yyuu/capistrano-play
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.8.23
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: a capistrano recipe to deploy Play! apps.
|
72
|
+
test_files: []
|