alerty 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/CHANGELOG.md +7 -0
- data/README.md +7 -2
- data/alerty.gemspec +1 -1
- data/example.yml +2 -0
- data/lib/alerty/cli.rb +11 -11
- data/lib/alerty/command.rb +2 -2
- data/lib/alerty/config.rb +15 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f1c92b7d3ec37c17af10d78fba346435c7be67e
|
4
|
+
data.tar.gz: 84616ba361045f8b94e544eea7626734077f212a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0479571dc19db4fb6c52f5fa1dca7cf023c15ce6947a68207ba41770027bda7fece31b4580ea11236f82e7a6ce84d3b04256026cce205956c2013a7d19e78d2c
|
7
|
+
data.tar.gz: 2547fee4e93f27d12acc0bc7eceb78ba376e329bc65850d35ae013875a2ef5032b5a1ead04571384343392fc2cd9ec3cfc839b7f3131e2609f200f09ab97d2bb
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,10 @@ gem install alerty
|
|
17
17
|
You can write a configuration file located at `/etc/sysconfig/alerty` (You can configure this path by `ALERTY_CONFIG_FILE` environment variable, or `-c` option):
|
18
18
|
|
19
19
|
```
|
20
|
+
log_path: STDOUT
|
20
21
|
log_level: 'debug'
|
22
|
+
timeout: 10
|
23
|
+
lock_path: /tmp/lock
|
21
24
|
plugins:
|
22
25
|
- type: stdout
|
23
26
|
```
|
@@ -34,9 +37,11 @@ $ alerty -c example.yml -- ls -l /something_not_exist
|
|
34
37
|
|
35
38
|
```
|
36
39
|
$ bin/alerty -h
|
37
|
-
-c, --config
|
40
|
+
-c, --config CONFIG_FILE config file path (default: /etc/sysconfig/alerty)
|
41
|
+
--log LOG_FILE log file path (default: STDOUT)
|
42
|
+
--log-level LOG_LEVEL log level (default: warn
|
38
43
|
-t, --timeout SECONDS timeout the command (default: no timeout)
|
39
|
-
-l, --lock LOCK_FILE exclusive lock file
|
44
|
+
-l, --lock LOCK_FILE exclusive lock file to prevent running a command duplicatedly (default: no lock)
|
40
45
|
```
|
41
46
|
|
42
47
|
## Plugins
|
data/alerty.gemspec
CHANGED
data/example.yml
CHANGED
data/lib/alerty/cli.rb
CHANGED
@@ -14,24 +14,24 @@ class Alerty
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
opts = {
|
18
|
-
|
19
|
-
|
20
|
-
exclusive: nil,
|
17
|
+
opts = {}
|
18
|
+
op.on('-c', '--config CONFIG_FILE', "config file path (default: /etc/sysconfig/alerty)") {|v|
|
19
|
+
opts[:config_path] = v
|
21
20
|
}
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
op.on('--log LOG_FILE', "log file path (default: STDOUT)") {|v|
|
22
|
+
opts[:log_path] = v
|
23
|
+
}
|
24
|
+
op.on('--log-level LOG_LEVEL', "log level (default: warn)") {|v|
|
25
|
+
opts[:log_level] = v
|
25
26
|
}
|
26
27
|
op.on('-t', '--timeout SECONDS', "timeout the command (default: no timeout)") {|v|
|
27
28
|
opts[:timeout] = v.to_i
|
28
29
|
}
|
29
30
|
op.on('-l', '--lock LOCK_FILE', "exclusive lock file to prevent running a command duplicatedly (default: no lock)") {|v|
|
30
|
-
opts[:
|
31
|
+
opts[:lock_path] = v
|
31
32
|
}
|
32
33
|
|
33
34
|
op.parse!(argv)
|
34
|
-
|
35
35
|
opts[:command] = argv.join(' ')
|
36
36
|
|
37
37
|
if opts[:command].empty?
|
@@ -48,8 +48,8 @@ class Alerty
|
|
48
48
|
usage e.message
|
49
49
|
end
|
50
50
|
|
51
|
-
Config.configure(
|
51
|
+
Config.configure(opts)
|
52
52
|
Config.plugins # load plugins in early stage
|
53
|
-
Command.new(command: opts[:command]
|
53
|
+
Command.new(command: opts[:command]).run!
|
54
54
|
end
|
55
55
|
end
|
data/lib/alerty/command.rb
CHANGED
data/lib/alerty/config.rb
CHANGED
@@ -4,12 +4,14 @@ require 'hashie/mash'
|
|
4
4
|
class Alerty
|
5
5
|
class Config
|
6
6
|
class << self
|
7
|
-
|
8
|
-
|
7
|
+
attr_reader :opts
|
8
|
+
|
9
|
+
def configure(opts)
|
10
|
+
@opts = opts
|
9
11
|
end
|
10
12
|
|
11
13
|
def config_path
|
12
|
-
@config_path ||= ENV['ALERTY_CONFIG_PATH'] || '/etc/sysconfig/alerty'
|
14
|
+
@config_path ||= opts[:config_path] || ENV['ALERTY_CONFIG_PATH'] || '/etc/sysconfig/alerty'
|
13
15
|
end
|
14
16
|
|
15
17
|
def config
|
@@ -17,11 +19,19 @@ class Alerty
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def log_path
|
20
|
-
config.log_path || 'STDOUT'
|
22
|
+
opts[:log_path] || config.log_path || 'STDOUT'
|
21
23
|
end
|
22
24
|
|
23
25
|
def log_level
|
24
|
-
config.log_level || 'warn'
|
26
|
+
opts[:log_level] || config.log_level || 'warn'
|
27
|
+
end
|
28
|
+
|
29
|
+
def timeout
|
30
|
+
opts[:timeout] || config.timeout
|
31
|
+
end
|
32
|
+
|
33
|
+
def lock_path
|
34
|
+
opts[:lock_path] || config.lock_path
|
25
35
|
end
|
26
36
|
|
27
37
|
def plugins
|