cassie 1.0.0.beta.15 → 1.0.0.beta.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cassie +63 -6
- data/lib/cassie/support/command_runner.rb +7 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e364e17d96eba783aa9410dc6e5ef856bfa6be12
|
4
|
+
data.tar.gz: f4f0fdfb2a8a27522d26dc417746b77b8b7f4b2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b72f96d2170b75c6d01cd5c212bc3b3cefcbe49a01f940eb6121b290076e614fd5d9d658f4c02c4e8b834ea65fb576752297c8607387a13d45bac15905329a7
|
7
|
+
data.tar.gz: a59f96bbf2615c064893e6f8f8dc58810e17ed5aa9e4c90c60c6123aa7cf2a45b48d56d77346e3622856adc1702ffe38bf1372f006ddaa8afcfd48bd46eec8fe
|
data/bin/cassie
CHANGED
@@ -1,10 +1,56 @@
|
|
1
1
|
#! ruby
|
2
|
-
|
3
|
-
|
2
|
+
require_relative '../lib/cassie'
|
3
|
+
|
4
|
+
def start
|
5
|
+
runner = Cassie::Support::CommandRunner.new("cassandra")
|
6
|
+
puts("Starting Cassandra...")
|
7
|
+
runner.run
|
8
|
+
runner.fail unless runner.finished?
|
9
|
+
|
10
|
+
if runner.output =~ /state jump to NORMAL/
|
11
|
+
puts "[#{green('✓')}] Cassandra Running"
|
12
|
+
else
|
13
|
+
runner.output.split("\n").grep(/ERROR/).each{|e| puts red(" " + e.gsub("; nested exception is:", "")) }
|
14
|
+
puts "[#{red('✘')}] Cassandra Failed to Start"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def stop
|
19
|
+
runner = Cassie::Support::CommandRunner.new("ps", ["-awx"])
|
20
|
+
runner.run!
|
21
|
+
# | grep cassandra | grep -v grep | awk '{print $1}'`
|
22
|
+
cassandra_awx = runner.output.split("\n").grep(/cassandra/)
|
23
|
+
pid = case cassandra_awx.length
|
24
|
+
when 0
|
25
|
+
puts red("No Cassandra process was found. Is Cassandra running?")
|
26
|
+
exit(1)
|
27
|
+
when 1
|
28
|
+
cassandra_awx.first.split(' ').first.to_i
|
29
|
+
else
|
30
|
+
puts red("Couldn't single out a Cassandra process:\n#{cassandra_awx}")
|
31
|
+
exit(1)
|
32
|
+
end
|
33
|
+
|
34
|
+
puts("Stopping Cassandra...")
|
35
|
+
Process.kill("TERM", pid)
|
36
|
+
loop do
|
37
|
+
sleep(0.1)
|
38
|
+
begin
|
39
|
+
Process.getpgid( pid )
|
40
|
+
rescue Errno::ESRCH
|
41
|
+
break
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
puts "[#{green('✓')}] Cassandra Stopped"
|
46
|
+
end
|
47
|
+
|
48
|
+
def kick
|
49
|
+
stop
|
50
|
+
start
|
4
51
|
end
|
5
52
|
|
6
53
|
def generate_config
|
7
|
-
require_relative '../lib/cassie'
|
8
54
|
opts = {}
|
9
55
|
if ARGV[1]
|
10
56
|
opts[:destination_path] = if ARGV[1][0] == "/"
|
@@ -23,7 +69,6 @@ def generate_config
|
|
23
69
|
end
|
24
70
|
|
25
71
|
def dump_structure
|
26
|
-
require_relative '../lib/cassie'
|
27
72
|
opts = {}
|
28
73
|
opts[:destination_path] = Cassie.paths[:schema_structure]
|
29
74
|
|
@@ -41,7 +86,6 @@ def dump_structure
|
|
41
86
|
end
|
42
87
|
|
43
88
|
def load_structure
|
44
|
-
require_relative '../lib/cassie'
|
45
89
|
opts = {}
|
46
90
|
opts[:source_path] = Cassie.paths[:schema_structure]
|
47
91
|
|
@@ -53,7 +97,20 @@ def load_structure
|
|
53
97
|
puts "[✓] Cassandra schema loaded from #{opts[:source_path]}"
|
54
98
|
end
|
55
99
|
|
100
|
+
def red(message)
|
101
|
+
"\e[1;31m#{message}\e[0m"
|
102
|
+
end
|
103
|
+
def green(message)
|
104
|
+
"\e[1;32m#{message}\e[0m"
|
105
|
+
end
|
106
|
+
|
56
107
|
case ARGV[0]
|
108
|
+
when "start"
|
109
|
+
start
|
110
|
+
when "stop"
|
111
|
+
stop
|
112
|
+
when "kick"
|
113
|
+
kick
|
57
114
|
when "configuration:generate"
|
58
115
|
generate_config
|
59
116
|
when "structure:dump"
|
@@ -61,5 +118,5 @@ when "structure:dump"
|
|
61
118
|
when "structure:load"
|
62
119
|
load_structure
|
63
120
|
else
|
64
|
-
puts
|
121
|
+
puts red("`#{ARGV[0]}` is not a supported command.")
|
65
122
|
end
|
@@ -30,7 +30,11 @@ module Cassie::Support
|
|
30
30
|
|
31
31
|
# Runs the command and raises if doesn't exit 0
|
32
32
|
def run!
|
33
|
-
|
33
|
+
fail unless exitcode == 0
|
34
|
+
end
|
35
|
+
|
36
|
+
def fail
|
37
|
+
Kernel.fail error_message
|
34
38
|
end
|
35
39
|
|
36
40
|
# Returns false if the command hasn't been executed yet
|
@@ -59,14 +63,14 @@ module Cassie::Support
|
|
59
63
|
|
60
64
|
def error_message
|
61
65
|
msg = "\n"
|
62
|
-
msg <<
|
66
|
+
msg << red(output)
|
63
67
|
msg << "\n---------------------"
|
64
68
|
msg << "\n\nfailed to execute `#{command}`.\n"
|
65
69
|
msg << "Please check the output above for any errors and make sure that `#{binary}` is installed in your PATH with proper permissions.\n"
|
66
70
|
msg
|
67
71
|
end
|
68
72
|
|
69
|
-
def
|
73
|
+
def red(message)
|
70
74
|
"\e[1m\e[31m#{message}\e[0m\e[22m"
|
71
75
|
end
|
72
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cassie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.
|
4
|
+
version: 1.0.0.beta.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Prothro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cassandra-driver
|