thundercat 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +12 -0
- data/bin/thundercat +6 -0
- data/bin/thundercat-upgrade +21 -0
- data/src/monitor/monitor.rb +0 -45
- data/src/monitor/standalone.rb +88 -0
- data/src/monitor/start_standalone.sh +1 -0
- data/src/monitor/stop_standalone.sh +13 -0
- data/src/rap/thundercat.rap +0 -0
- metadata +5 -2
data/README.md
CHANGED
@@ -55,6 +55,18 @@ This deploys a rap archive to a thundercat server e.g.
|
|
55
55
|
-r is to specify your rap archive and -u is the url of the deploy api where your thundercat instance is running. -k is your api_key which is configured in your
|
56
56
|
thundercat server.
|
57
57
|
|
58
|
+
## Upgrading
|
59
|
+
|
60
|
+
There is a very crude upgrade script starting from thundercat-0.0.8 - This is the process:
|
61
|
+
|
62
|
+
* stop your exising monitor using ./stop.sh
|
63
|
+
* copy your webapps/thundercat/config.yml somewhere safe
|
64
|
+
* thundercat-upgrade your_thundercat_install_folder
|
65
|
+
* start the monitor again using ./start.sh
|
66
|
+
* replace webapps/thundercat/config.yml with your original one
|
67
|
+
* restart monitor - ./stop.sh && ./start.sh
|
68
|
+
* check everything is ok
|
69
|
+
|
58
70
|
## Screenshots
|
59
71
|
|
60
72
|
### Admin Page
|
data/bin/thundercat
CHANGED
@@ -12,6 +12,9 @@ else
|
|
12
12
|
monitor = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/monitor.rb'
|
13
13
|
start_script = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/start.sh'
|
14
14
|
stop_script = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/stop.sh'
|
15
|
+
standalone = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/standalone.rb'
|
16
|
+
standalone_start_script = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/start_standalone.sh'
|
17
|
+
standalone_stop_script = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/stop_standalone.sh'
|
15
18
|
|
16
19
|
target_dir = "#{name}"
|
17
20
|
if File.exists?(target_dir)
|
@@ -27,6 +30,9 @@ else
|
|
27
30
|
FileUtils.cp(monitor, target_dir)
|
28
31
|
FileUtils.cp(start_script, target_dir)
|
29
32
|
FileUtils.cp(stop_script, target_dir)
|
33
|
+
FileUtils.cp(standalone, target_dir)
|
34
|
+
FileUtils.cp(standalone_start_script, target_dir)
|
35
|
+
FileUtils.cp(standalone_stop_script, target_dir)
|
30
36
|
puts "[ThunderCat] Successfully created ThunderCat structure at: #{target_dir}"
|
31
37
|
end
|
32
38
|
rescue => e
|
data/bin/thundercat-upgrade
CHANGED
@@ -29,6 +29,27 @@ else
|
|
29
29
|
FileUtils.cp(rap, "#{target_dir}/webapps")
|
30
30
|
end
|
31
31
|
|
32
|
+
if existing_version > "0.0.256" and existing_version < "0.0.261"
|
33
|
+
# create standalone new files
|
34
|
+
rap = File.dirname(File.expand_path(__FILE__)) + '/../src/rap/thundercat.rap'
|
35
|
+
monitor = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/monitor.rb'
|
36
|
+
standalone = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/standalone.rb'
|
37
|
+
standalone_start_script = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/start_standalone.sh'
|
38
|
+
standalone_stop_script = File.dirname(File.expand_path(__FILE__)) + '/../src/monitor/stop_standalone.sh'
|
39
|
+
|
40
|
+
# remove old monitor and replace with new monitor
|
41
|
+
FileUtils.rm_rf("#{target_dir}/monitor.rb") if File.exists?("#{target_dir}/monitor.rb")
|
42
|
+
FileUtils.cp(monitor, target_dir)
|
43
|
+
|
44
|
+
# copy in new standalone scripts
|
45
|
+
FileUtils.cp(standalone, target_dir)
|
46
|
+
FileUtils.cp(standalone_start_script, target_dir)
|
47
|
+
FileUtils.cp(standalone_stop_script, target_dir)
|
48
|
+
|
49
|
+
# drop in new thundercat rap
|
50
|
+
FileUtils.cp(rap, "#{target_dir}/webapps")
|
51
|
+
end
|
52
|
+
|
32
53
|
puts "[ThunderCat] Successfully updated ThunderCat at: #{target_dir}"
|
33
54
|
|
34
55
|
rescue => e
|
data/src/monitor/monitor.rb
CHANGED
@@ -24,23 +24,6 @@ class Decision
|
|
24
24
|
`cd #{webapps_dir}/thundercat; ./start.sh`
|
25
25
|
end
|
26
26
|
|
27
|
-
def standalone_decide(option, base, relative, type)
|
28
|
-
zip_file = base + '/' + relative
|
29
|
-
zip_dir = path_without_ext(zip_file, base)
|
30
|
-
if option == :create
|
31
|
-
clean_standalone(zip_dir, zip_file, base) if rap_already_deployed?(zip_dir)
|
32
|
-
deploy_standalone(zip_file, zip_dir, base)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def standalone_initial(standalone_dir)
|
37
|
-
Dir.entries(standalone_dir).each do |entry|
|
38
|
-
if entry.match(/.zip$/)
|
39
|
-
decide(:create, standalone_dir, entry, 'file')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
27
|
private
|
45
28
|
|
46
29
|
def deploy_rap(rap_file, rap_dir, base)
|
@@ -69,12 +52,6 @@ class Decision
|
|
69
52
|
|
70
53
|
end
|
71
54
|
|
72
|
-
def deploy_standalone(zip_file, zip_dir, base)
|
73
|
-
Rappa.new(:input_archive => zip_file, :output_archive => base).standalone_expand
|
74
|
-
puts "[ThunderCat] Successfully deployed standalone zip archive at: #{zip_file}"
|
75
|
-
archive_zip(zip_file, base)
|
76
|
-
end
|
77
|
-
|
78
55
|
def stop_app(rap_dir)
|
79
56
|
rap_file = rap_dir + '/rap.yml'
|
80
57
|
if File.exists?(rap_file)
|
@@ -91,20 +68,11 @@ class Decision
|
|
91
68
|
FileUtils.mv(rap_dir, "#{base}/../archive/#{file_without_ext(rap_file)}.#{Time.now.to_i}")
|
92
69
|
end
|
93
70
|
|
94
|
-
def archive_existing_standalone(zip_dir, zip_file, base)
|
95
|
-
FileUtils.mv(zip_dir, "#{base}/../standalone_archive/#{file_without_ext(zip_file)}.#{Time.now.to_i}")
|
96
|
-
end
|
97
|
-
|
98
71
|
def archive_rap(rap_file, base)
|
99
72
|
FileUtils.mv(rap_file, "#{base}/../archive/#{file_without_ext(rap_file)}.#{Time.now.to_i}.rap")
|
100
73
|
puts "[ThunderCat] archived rap file: #{rap_file}"
|
101
74
|
end
|
102
75
|
|
103
|
-
def archive_zip(zip_file, base)
|
104
|
-
FileUtils.mv(zip_file, "#{base}/../standalone_archive/#{file_without_ext(zip_file)}.#{Time.now.to_i}.zip")
|
105
|
-
puts "[ThunderCat] archived standalone zip file: #{zip_file}"
|
106
|
-
end
|
107
|
-
|
108
76
|
def rap_already_deployed?(rap_dir)
|
109
77
|
File.exists?(rap_dir)
|
110
78
|
end
|
@@ -114,10 +82,6 @@ class Decision
|
|
114
82
|
archive_existing_app(rap_dir, rap_file, base)
|
115
83
|
end
|
116
84
|
|
117
|
-
def clean_standalone(zip_dir, zip_file, base)
|
118
|
-
archive_existing_standalone(zip_dir, zip_file, base)
|
119
|
-
end
|
120
|
-
|
121
85
|
def path_without_ext(file, base)
|
122
86
|
base_name = File.basename(file)
|
123
87
|
base + '/' + base_name.chomp(File.extname(base_name))
|
@@ -136,20 +100,11 @@ class Monitor
|
|
136
100
|
def self.go
|
137
101
|
begin
|
138
102
|
webapps_dir = File.dirname(__FILE__) + '/webapps'
|
139
|
-
standalone_dir = File.dirname(__FILE__) + '/standalone'
|
140
103
|
Decision.new.initial(webapps_dir)
|
141
|
-
Decision.new.standalone_initial(standalone_dir)
|
142
104
|
FSSM.monitor(webapps_dir, '**/*.rap', :directories => true) do
|
143
105
|
update { |base, relative, type| puts "updated #{base}, #{relative}, #{type}" }
|
144
106
|
delete { |base, relative, type| puts "delete #{base}, #{relative}, #{type}" }
|
145
107
|
create { |base, relative, type| Decision.new.decide(:create, base, relative, type) }
|
146
|
-
|
147
|
-
FSSM.monitor(standalone_dir, '**/*.zip', :directories => true) do
|
148
|
-
update { |dir, relative, type| puts "updated #{dir}, #{relative}, #{type}" }
|
149
|
-
delete { |dir, relative, type| puts "delete #{dir}, #{relative}, #{type}" }
|
150
|
-
create { |dir, relative, type| Decision.new.standalone_decide(:create, dir, relative, type) }
|
151
|
-
end
|
152
|
-
|
153
108
|
end
|
154
109
|
|
155
110
|
rescue => e
|
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fssm'
|
3
|
+
require 'dante'
|
4
|
+
require 'yaml'
|
5
|
+
require 'rappa'
|
6
|
+
|
7
|
+
class Decision
|
8
|
+
|
9
|
+
def standalone_decide(option, base, relative, type)
|
10
|
+
zip_file = base + '/' + relative
|
11
|
+
zip_dir = path_without_ext(zip_file, base)
|
12
|
+
if option == :create
|
13
|
+
clean_standalone(zip_dir, zip_file, base) if zip_already_deployed?(zip_dir)
|
14
|
+
deploy_standalone(zip_file, zip_dir, base)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def standalone_initial(standalone_dir)
|
19
|
+
Dir.entries(standalone_dir).each do |entry|
|
20
|
+
if entry.match(/.zip$/)
|
21
|
+
decide(:create, standalone_dir, entry, 'file')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def deploy_standalone(zip_file, zip_dir, base)
|
29
|
+
Rappa.new(:input_archive => zip_file, :output_archive => base).standalone_expand
|
30
|
+
puts "[ThunderCat] Successfully deployed standalone zip archive at: #{zip_file}"
|
31
|
+
archive_zip(zip_file, base)
|
32
|
+
end
|
33
|
+
|
34
|
+
def archive_existing_standalone(zip_dir, zip_file, base)
|
35
|
+
FileUtils.mv(zip_dir, "#{base}/../standalone_archive/#{file_without_ext(zip_file)}.#{Time.now.to_i}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def archive_zip(zip_file, base)
|
39
|
+
FileUtils.mv(zip_file, "#{base}/../standalone_archive/#{file_without_ext(zip_file)}.#{Time.now.to_i}.zip")
|
40
|
+
puts "[ThunderCat] archived standalone zip file: #{zip_file}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def zip_already_deployed?(rap_dir)
|
44
|
+
File.exists?(rap_dir)
|
45
|
+
end
|
46
|
+
|
47
|
+
def clean_standalone(zip_dir, zip_file, base)
|
48
|
+
archive_existing_standalone(zip_dir, zip_file, base)
|
49
|
+
end
|
50
|
+
|
51
|
+
def path_without_ext(file, base)
|
52
|
+
base_name = File.basename(file)
|
53
|
+
base + '/' + base_name.chomp(File.extname(base_name))
|
54
|
+
end
|
55
|
+
|
56
|
+
def file_without_ext(file)
|
57
|
+
base_name = File.basename(file)
|
58
|
+
base_name.chomp(File.extname(base_name))
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
class Standalone
|
65
|
+
|
66
|
+
def self.go
|
67
|
+
begin
|
68
|
+
standalone_dir = File.dirname(__FILE__) + '/standalone'
|
69
|
+
Decision.new.standalone_initial(standalone_dir)
|
70
|
+
FSSM.monitor(standalone_dir, '**/*.zip', :directories => true) do
|
71
|
+
update { |base, relative, type| puts "updated #{base}, #{relative}, #{type}" }
|
72
|
+
delete { |base, relative, type| puts "delete #{base}, #{relative}, #{type}" }
|
73
|
+
create { |base, relative, type| Decision.new.standalone_decide(:create, base, relative, type) }
|
74
|
+
end
|
75
|
+
|
76
|
+
rescue => e
|
77
|
+
puts "[ThunderCat] Standalone encountered an error: #{e}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
Dante.run('standalone') do |opts|
|
84
|
+
Standalone.go
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
./standalone.rb -P ./log/standalone.pid -d -l ./log/standalone.log
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
begin
|
5
|
+
|
6
|
+
pid = File.read(File.dirname(__FILE__) + '/log/standalone.pid').strip
|
7
|
+
`kill -9 #{pid}`
|
8
|
+
FileUtils.rm(File.dirname(__FILE__) + '/log/standalone.pid')
|
9
|
+
puts "[ThunderCat] stopped thundercat standalone with process: #{pid}"
|
10
|
+
|
11
|
+
rescue => e
|
12
|
+
puts "[ThunderCat] Oops something went wrong: #{e}"
|
13
|
+
end
|
data/src/rap/thundercat.rap
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thundercat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
@@ -234,6 +234,9 @@ files:
|
|
234
234
|
- src/monitor/monitor.rb
|
235
235
|
- src/monitor/start.sh
|
236
236
|
- src/monitor/stop.sh
|
237
|
+
- src/monitor/standalone.rb
|
238
|
+
- src/monitor/start_standalone.sh
|
239
|
+
- src/monitor/stop_standalone.sh
|
237
240
|
- README.md
|
238
241
|
- bin/thundercat
|
239
242
|
- bin/thundercat-upgrade
|