tuesday 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/tuesday +4 -0
- data/lib/kitchen +0 -0
- data/lib/tuesday.rb +169 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f4a331e53e1663e5526b7345a9b134dbc0a2b3fd
|
4
|
+
data.tar.gz: 138c1f7632408e179bac1b8b5e12f6c9bbee4f2d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cfb7af331317437201c1586bc26d8b058d50f5cc3915ff76e53a85a83e34a5231037e2a6e615c468fc582860c8ea8307f98e93c58001e3615cbf35e5993300eb
|
7
|
+
data.tar.gz: 5ef5601d2d301a05bf29cce24028b3510871cea8120957d183e68390c72989f69c09ecf8d3d9251cbc5d054af41d0ce4ef104740c48ace9c5c5f3c50da48c2ff
|
data/bin/tuesday
ADDED
data/lib/kitchen
ADDED
File without changes
|
data/lib/tuesday.rb
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
class Tuesday
|
4
|
+
def self.run
|
5
|
+
puts "#praisecatgod"
|
6
|
+
settings = {}
|
7
|
+
|
8
|
+
begin
|
9
|
+
# Exceptions raised by this code will
|
10
|
+
# be caught by the following rescue clause
|
11
|
+
settings = eval "{#{IO.readlines('Menufile').join.strip}}"
|
12
|
+
|
13
|
+
rescue
|
14
|
+
puts "You don't have a Menufile. Please consult http://tuesdayrb.me for support.
|
15
|
+
Thank you please come again."
|
16
|
+
abort
|
17
|
+
end
|
18
|
+
|
19
|
+
output = `bundle install --without production`
|
20
|
+
puts output
|
21
|
+
|
22
|
+
output = `gem list`
|
23
|
+
#puts output
|
24
|
+
unicorn_output = output.match(/unicorn (.*)\n/)
|
25
|
+
if unicorn_output.nil?
|
26
|
+
puts "I'm sorry...you appear to be missing Unicorn. Don't worry I got you ;)"
|
27
|
+
puts `gem install unicorn`
|
28
|
+
else
|
29
|
+
puts "reservation made for mr. unicorn"
|
30
|
+
end
|
31
|
+
output = `pwd`
|
32
|
+
app_name = output.split("/").last
|
33
|
+
app_name.strip!
|
34
|
+
puts "I see you would like the #{app_name}. Very fine choice"
|
35
|
+
|
36
|
+
base_unicorn = "
|
37
|
+
working_directory '/var/www/#{app_name}'
|
38
|
+
|
39
|
+
pid '/var/www/#{app_name}/pids/unicorn.pid'
|
40
|
+
|
41
|
+
stderr_path '/var/www/#{app_name}/logs/unicorn.log'
|
42
|
+
stdout_path '/var/www/#{app_name}/logs/unicorn.log'
|
43
|
+
|
44
|
+
listen '/tmp/unicorn.#{app_name}.sock'
|
45
|
+
|
46
|
+
# Number of processes
|
47
|
+
# worker_processes 4
|
48
|
+
worker_processes 1
|
49
|
+
|
50
|
+
# Time-out
|
51
|
+
timeout 30
|
52
|
+
|
53
|
+
"
|
54
|
+
puts `rm unicorn.rb`
|
55
|
+
puts `echo "#{base_unicorn}" >> unicorn.rb`
|
56
|
+
|
57
|
+
puts `mkdir logs pids`
|
58
|
+
|
59
|
+
nginx = `which nginx`
|
60
|
+
if nginx == ""
|
61
|
+
#install nginx
|
62
|
+
if `uname`.strip == "Darwin"
|
63
|
+
puts `brew install nginx`
|
64
|
+
else
|
65
|
+
puts `apt-get install nginx`
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#kill the bad nginx
|
70
|
+
puts "Killing the bad nginx"
|
71
|
+
puts `rm /etc/nginx/conf.d/defaults`
|
72
|
+
puts `rm /etc/nginx/sites-available/*`
|
73
|
+
puts `rm /etc/nginx/sites-enabled/*`
|
74
|
+
puts `rm /etc/nginx/conf.d/default.conf`
|
75
|
+
|
76
|
+
#add app to kitchen
|
77
|
+
kitchen = eval "#{IO.readlines('/usr/local/bin/kitchen').join.strip}"
|
78
|
+
if kitchen.nil?
|
79
|
+
kitchen = {}
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
#build new temp default.conf file
|
84
|
+
|
85
|
+
#kill old default.conf
|
86
|
+
#puts "Reloading nginx config"
|
87
|
+
#
|
88
|
+
#write new default conf file
|
89
|
+
|
90
|
+
def gen_nginx(app_name, domain_name)
|
91
|
+
"
|
92
|
+
|
93
|
+
upstream #{app_name} {
|
94
|
+
# Path to Unicorn SOCK file, as defined previously
|
95
|
+
server unix:/tmp/unicorn.#{app_name}.sock fail_timeout=0;
|
96
|
+
}
|
97
|
+
|
98
|
+
server {
|
99
|
+
|
100
|
+
|
101
|
+
listen 80;
|
102
|
+
|
103
|
+
# Set the server name, similar to Apache's settings
|
104
|
+
server_name localhost #{app_name}.#{domain_name};
|
105
|
+
|
106
|
+
# Application root, as defined previously
|
107
|
+
root /var/www/#{app_name}/public;
|
108
|
+
|
109
|
+
try_files $uri/index.html $uri @#{app_name};
|
110
|
+
|
111
|
+
location @#{app_name} {
|
112
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
113
|
+
proxy_set_header Host $http_host;
|
114
|
+
proxy_redirect off;
|
115
|
+
proxy_pass http://#{app_name};
|
116
|
+
}
|
117
|
+
|
118
|
+
error_page 500 502 503 504 /500.html;
|
119
|
+
client_max_body_size 4G;
|
120
|
+
keepalive_timeout 10;
|
121
|
+
|
122
|
+
}
|
123
|
+
|
124
|
+
"
|
125
|
+
end
|
126
|
+
|
127
|
+
new_nginx = ""
|
128
|
+
|
129
|
+
#kill old unicorns
|
130
|
+
puts "Grinding up the unicorns"
|
131
|
+
kitchen.each do |key,value|
|
132
|
+
str = "#{value[:pwd]}/pids/unicorn.pid"
|
133
|
+
puts str
|
134
|
+
unicorn_id = IO.readlines(str).join.strip
|
135
|
+
puts `kill "#{unicorn_id}"`
|
136
|
+
end
|
137
|
+
|
138
|
+
#run new unicorns
|
139
|
+
|
140
|
+
puts "Making your order"
|
141
|
+
|
142
|
+
if kitchen["#{app_name}".to_sym]
|
143
|
+
kitchen.delete("#{app_name}".to_sym)
|
144
|
+
end
|
145
|
+
|
146
|
+
kitchen["#{app_name}".to_sym] = {pwd: "#{`pwd`}".strip}
|
147
|
+
|
148
|
+
puts "Making the patties"
|
149
|
+
kitchen.each do |key,value|
|
150
|
+
puts `unicorn -c "#{value[:pwd]}"/unicorn.rb -D`
|
151
|
+
value[:pid] = IO.readlines("#{value[:pwd]}/pids/unicorn.pid").join.strip
|
152
|
+
|
153
|
+
new_nginx += gen_nginx(key,settings[:domain])
|
154
|
+
end
|
155
|
+
|
156
|
+
File.write('/usr/local/bin/kitchen', "#{kitchen}")
|
157
|
+
File.write("/etc/nginx/conf.d/default.conf",new_nginx)
|
158
|
+
|
159
|
+
#restart nginx
|
160
|
+
puts `service nginx restart`
|
161
|
+
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
kitchen_path = File.join( File.dirname(__FILE__), 'kitchen' )
|
166
|
+
file = File.open(kitchen_path)
|
167
|
+
|
168
|
+
`cp "#{kitchen_path}" /usr/local/bin/kitchen`
|
169
|
+
`chmod a+x /usr/local/bin/kitchen`
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tuesday
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yves DeSousa
|
8
|
+
- Max Rogers
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-10-19 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Deploys Rack apps to DigitalOcean with one command.
|
15
|
+
email: yvonne@yvds.net
|
16
|
+
executables:
|
17
|
+
- tuesday
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- bin/tuesday
|
22
|
+
- lib/kitchen
|
23
|
+
- lib/tuesday.rb
|
24
|
+
homepage: http://tuesdayrb.me
|
25
|
+
licenses:
|
26
|
+
- WTFPL
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.2.2
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Fast Casual DigitalOcean Deployment
|
48
|
+
test_files: []
|