pushapp 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pushapp/remote.rb +1 -1
- data/lib/pushapp/tasks/base.rb +20 -0
- data/lib/pushapp/tasks/foreman_export.rb +66 -1
- data/lib/pushapp/tasks/nginx_export.rb +32 -0
- data/lib/pushapp/tasks/script.rb +0 -8
- data/lib/pushapp/tasks/upstart.rb +62 -0
- data/lib/pushapp/version.rb +1 -1
- data/templates/config.rb.erb +12 -5
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29e1709edb9f11e1d53da1056e29e02b2083fbf5
|
4
|
+
data.tar.gz: 256aa9bcebac136299544ecfe84b81aac263ed0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ed832d2791477b269fa653c6b84f193ede75e567ca717eef086fc857fffb1d60c2ce11eeb55e5e9672d018b207cfa06a731c95daa01424ef19d569e721cc730
|
7
|
+
data.tar.gz: d802a27dd8d8c8aae5864768cedc4b7be8a164701819f1ef927affd30ca691b07da390d38a3022d281e65db4c745ce60b2b6e9047e5c32deb7537d0ad117c93d
|
data/lib/pushapp/remote.rb
CHANGED
data/lib/pushapp/tasks/base.rb
CHANGED
@@ -15,6 +15,26 @@ module Pushapp
|
|
15
15
|
def run
|
16
16
|
end
|
17
17
|
|
18
|
+
def env
|
19
|
+
Hash[env_options.map {|k, v| [k.to_s, v.to_s] }]
|
20
|
+
end
|
21
|
+
|
22
|
+
def env_options
|
23
|
+
options[:env] || {}
|
24
|
+
end
|
25
|
+
|
26
|
+
def sudo
|
27
|
+
options[:sudo] || 'sudo'
|
28
|
+
end
|
29
|
+
|
30
|
+
def system cmd
|
31
|
+
Pipe.run cmd
|
32
|
+
end
|
33
|
+
|
34
|
+
def app_name_from_path
|
35
|
+
options[:remote].path ? options[:remote].path.split('/').last : nil
|
36
|
+
end
|
37
|
+
|
18
38
|
def self.register_as name
|
19
39
|
Pushapp::Config.register_task name, self
|
20
40
|
end
|
@@ -5,7 +5,72 @@ module Pushapp
|
|
5
5
|
class ForemanExport < Base
|
6
6
|
|
7
7
|
def run
|
8
|
-
|
8
|
+
system "#{sudo} bundle exec foreman export #{arguments}"
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def arguments
|
14
|
+
args = ["#{foreman_format} #{foreman_location}"]
|
15
|
+
args << "-f #{foreman_procfile}" if foreman_procfile
|
16
|
+
args << "-a #{foreman_app}" if foreman_app
|
17
|
+
args << "-u #{foreman_user}" if foreman_user
|
18
|
+
args << "-d #{foreman_directory}" if foreman_directory
|
19
|
+
args << "-e #{foreman_env}" if foreman_env
|
20
|
+
args << "-l #{foreman_log}"
|
21
|
+
args << "-p #{options[:foreman_port]}" if options[:foreman_port]
|
22
|
+
args << "-c #{options[:foreman_concurrency]}" if options[:foreman_concurrency]
|
23
|
+
args << "-t #{options[:foreman_template]}" if options[:foreman_template]
|
24
|
+
args.join(' ')
|
25
|
+
end
|
26
|
+
|
27
|
+
def foreman_format
|
28
|
+
options[:foreman_format] || "upstart"
|
29
|
+
end
|
30
|
+
|
31
|
+
def foreman_location
|
32
|
+
options[:foreman_location] || foreman_format == 'upstart' ? '/etc/init' : nil
|
33
|
+
end
|
34
|
+
|
35
|
+
def foreman_procfile
|
36
|
+
options[:foreman_procfile] || find_procfile
|
37
|
+
end
|
38
|
+
|
39
|
+
def foreman_app
|
40
|
+
options[:foreman_app] || app_name_from_path
|
41
|
+
end
|
42
|
+
|
43
|
+
def foreman_user
|
44
|
+
options[:foreman_user] || options[:remote].user
|
45
|
+
end
|
46
|
+
|
47
|
+
def foreman_directory
|
48
|
+
options[:foreman_directory] || options[:remote].path
|
49
|
+
end
|
50
|
+
|
51
|
+
def foreman_env
|
52
|
+
options[:foreman_env] || find_dot_env_file
|
53
|
+
end
|
54
|
+
|
55
|
+
def foreman_log
|
56
|
+
options[:foreman_log] || 'log/foreman'
|
57
|
+
end
|
58
|
+
|
59
|
+
def find_dot_env_file
|
60
|
+
dot_env = ['.env', rails_env].compact.join('.')
|
61
|
+
return dot_env if File.exists?(dot_env)
|
62
|
+
return '.env' if File.exists?('.env')
|
63
|
+
end
|
64
|
+
|
65
|
+
def find_procfile
|
66
|
+
procfile = ['config/deploys/Procfile', rails_env].join('.')
|
67
|
+
return procfile if File.exists?(procfile)
|
68
|
+
procfile = ['Procfile', rails_env].join('.')
|
69
|
+
return procfile if File.exists?(procfile)
|
70
|
+
end
|
71
|
+
|
72
|
+
def rails_env
|
73
|
+
env['RAILS_ENV']
|
9
74
|
end
|
10
75
|
|
11
76
|
register_as :foreman_export
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'pushapp/tasks/base'
|
2
|
+
|
3
|
+
module Pushapp
|
4
|
+
module Tasks
|
5
|
+
class NginxExport < Nginx
|
6
|
+
def run
|
7
|
+
system "#{sudo} cp #{nginx_conf} #{nginx_sites}"
|
8
|
+
|
9
|
+
unless options[:nginx_skip_reload]
|
10
|
+
system "#{sudo} /etc/init.d/nginx reload"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
register_as :nginx_export
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def nginx_conf
|
19
|
+
options[:nginx_conf] || find_nginx_conf
|
20
|
+
end
|
21
|
+
|
22
|
+
def nginx_sites
|
23
|
+
options[:nginx_sites] || '/etc/nginx/sites-enabled'
|
24
|
+
end
|
25
|
+
|
26
|
+
def find_nginx_conf
|
27
|
+
file = "config/deploys/#{app_name_from_path}.nginx.conf"
|
28
|
+
return file if File.exists?(file)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pushapp/tasks/script.rb
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'pushapp/tasks/base'
|
2
|
+
|
3
|
+
module Pushapp
|
4
|
+
module Tasks
|
5
|
+
class Upstart < Base
|
6
|
+
def upstart_job
|
7
|
+
@upstart_job ||= options[:upstart_job] || job_name_from_path
|
8
|
+
end
|
9
|
+
|
10
|
+
def upstart_jobs
|
11
|
+
options[:upstart_jobs] || []
|
12
|
+
end
|
13
|
+
|
14
|
+
def job_name_from_path
|
15
|
+
options[:remote].path ? options[:remote].path.split('/').last : nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def jobs
|
19
|
+
@jobs ||= upstart_jobs.empty? ? [upstart_job] : upstart_jobs.map {|j| [upstart_job, j].compact.join("-")}
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
jobs.each { |j| run_on(j) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def run_on job
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class UpstartStart < Upstart
|
31
|
+
def run_on job
|
32
|
+
system "#{sudo} initctl start #{job}"
|
33
|
+
end
|
34
|
+
|
35
|
+
register_as :upstart_start
|
36
|
+
end
|
37
|
+
|
38
|
+
class UpstartStop < Upstart
|
39
|
+
def run_on job
|
40
|
+
system "#{sudo} initctl stop #{job}"
|
41
|
+
end
|
42
|
+
|
43
|
+
register_as :upstart_stop
|
44
|
+
end
|
45
|
+
|
46
|
+
class UpstartRestart < Upstart
|
47
|
+
def run_on job
|
48
|
+
system "#{sudo} initctl start #{job} || initctl restart #{job}"
|
49
|
+
end
|
50
|
+
|
51
|
+
register_as :upstart_restart
|
52
|
+
end
|
53
|
+
|
54
|
+
class UpstartReload < Upstart
|
55
|
+
def run_on job
|
56
|
+
system "#{sudo} initctl start #{job} || initctl restart #{job}"
|
57
|
+
end
|
58
|
+
|
59
|
+
register_as :upstart_reload
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/pushapp/version.rb
CHANGED
data/templates/config.rb.erb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
# Pushapp Configuration File
|
2
|
+
require 'pushapp/tasks/upstart'
|
3
|
+
require 'pushapp/tasks/nginx_export'
|
4
|
+
require 'pushapp/tasks/foreman_export'
|
2
5
|
|
3
6
|
# Sample remote definition:
|
4
7
|
#
|
@@ -17,14 +20,18 @@
|
|
17
20
|
# worker: true
|
18
21
|
# end
|
19
22
|
|
20
|
-
remote '
|
21
|
-
web:true, db: true, env: {RAILS_ENV: 'staging'}
|
23
|
+
remote 'production', 'app@server3:/home/app/app', env: {RAILS_ENV: 'production'}
|
22
24
|
|
23
25
|
on :setup do
|
24
|
-
|
26
|
+
task :nginx_export
|
27
|
+
rake('db:create db:migrate db:seed')
|
28
|
+
rake('precompile:assets', env: {RAILS_GROUP: :assets})
|
29
|
+
task(:foreman_export)
|
30
|
+
task(:upstart_restart)
|
25
31
|
end
|
26
32
|
|
27
33
|
on :push do
|
28
|
-
rake('db:migrate')
|
29
|
-
rake('precompile:assets', env: {RAILS_GROUP: :assets})
|
34
|
+
rake('db:migrate')
|
35
|
+
rake('precompile:assets', env: {RAILS_GROUP: :assets})
|
36
|
+
task(:upstart_restart)
|
30
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Korolev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -92,8 +92,10 @@ files:
|
|
92
92
|
- lib/pushapp/remote.rb
|
93
93
|
- lib/pushapp/tasks/base.rb
|
94
94
|
- lib/pushapp/tasks/foreman_export.rb
|
95
|
+
- lib/pushapp/tasks/nginx_export.rb
|
95
96
|
- lib/pushapp/tasks/rake.rb
|
96
97
|
- lib/pushapp/tasks/script.rb
|
98
|
+
- lib/pushapp/tasks/upstart.rb
|
97
99
|
- lib/pushapp/version.rb
|
98
100
|
- pushapp.gemspec
|
99
101
|
- templates/config.rb.erb
|