evesync 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -3
- data/bin/evesync +27 -16
- data/lib/evesync/config.rb +6 -6
- data/lib/evesync/constants.rb +1 -1
- data/lib/evesync/err.rb +4 -1
- data/lib/evesync/ipc/data.rb +5 -1
- data/lib/evesync/ipc/ipc.rb +2 -2
- data/lib/evesync/log.rb +3 -1
- data/lib/evesync/ntp.rb +12 -1
- data/lib/evesync/os/linux/arch/package_manager.rb +2 -0
- data/lib/evesync/os/linux/rhel/package_manager.rb +5 -2
- data/lib/evesync/trigger.rb +1 -0
- data/lib/evesync/watcher.rb +0 -1
- data/lib/evesync.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dfabc12dbd6228ae7855ffd195a96ebc4b2c9c2164e477d41eed688f9b4bac2
|
4
|
+
data.tar.gz: 2888ea5a7979af4fe27b519c864e57867d08f74bf5a1f44704eb90b9b49c6f1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 221f04a0720876831f2da1f0c70cdcb97dca47f74f0fa50ccd6d8f92ac8efce5c4301d4d3c77601f1baf463faf3a8217e3a642a69cb9a7f35fd7f7ba0ef59c0a
|
7
|
+
data.tar.gz: 96720c0c6380d98df1f32e1466612aebb33365eff865749133545a31215896560b221297b72b3b3f8fe1138f5c435c48320c9c7b7c246e9ac21e6d6e1459b3a4
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ GEMFILE = "evesync-#{VERSION}.gem".freeze
|
|
9
9
|
task default: %i[lint build]
|
10
10
|
|
11
11
|
task :lint do
|
12
|
-
sh 'rubocop -l lib' if find_executable 'rubocop'
|
12
|
+
sh 'rubocop -l lib bin' if find_executable 'rubocop'
|
13
13
|
end
|
14
14
|
|
15
15
|
task :rdoc do
|
@@ -37,8 +37,7 @@ task :clean, [:remove_rpm] do |_t, args|
|
|
37
37
|
rm_rf('mkmf.log')
|
38
38
|
rm_rf(Dir['*.zip'])
|
39
39
|
rm_rf('RPM') if args[:remove_rpm] == 1
|
40
|
-
rm_rf(
|
41
|
-
rm_rf(GEMFILE)
|
40
|
+
rm_rf(Dir['evesync-*.gem'])
|
42
41
|
end
|
43
42
|
|
44
43
|
task todos: :todo
|
data/bin/evesync
CHANGED
@@ -22,6 +22,22 @@ $program = File.basename($0)
|
|
22
22
|
#Evesync::Log.level = :warn
|
23
23
|
Evesync::Log.simple = true
|
24
24
|
|
25
|
+
def kill_by_pid(daemon)
|
26
|
+
begin
|
27
|
+
Process.kill('TERM', File.read("/var/run/evesync/#{daemon}.pid").to_i)
|
28
|
+
rescue Errno::ESRCH
|
29
|
+
puts("#{daemon} already killed")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def spawn_daemon(daemon)
|
34
|
+
pid = spawn(daemon,
|
35
|
+
:err => "/var/log/evesync/#{daemon}.log",
|
36
|
+
:out=>:err)
|
37
|
+
File.write("/var/run/evesync/#{daemon}.pid", pid)
|
38
|
+
pid
|
39
|
+
end
|
40
|
+
|
25
41
|
OptionParser.new do |parser|
|
26
42
|
parser.banner = "#{$program} [OPTIONS...]
|
27
43
|
|
@@ -68,26 +84,20 @@ OptionParser.new do |parser|
|
|
68
84
|
|
69
85
|
# TODO: refactor
|
70
86
|
parser.on('-r', '--run', 'Start daemons') do
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
File.write('/var/run/evesync/evedatad.pid', data_pid)
|
78
|
-
File.write('/var/run/evesync/evemond.pid', mon_pid)
|
79
|
-
File.write('/var/run/evesync/evehand.pid', hand_pid)
|
80
|
-
File.write('/var/run/evesync/evesyncd.pid', sync_pid)
|
87
|
+
FileUtils.mkdir_p '/var/log/evesync'
|
88
|
+
FileUtils.mkdir_p '/var/run/evesync'
|
89
|
+
spawn_daemon 'evedatad'
|
90
|
+
spawn_daemon 'evemond'
|
91
|
+
spawn_daemon 'evehand'
|
92
|
+
spawn_daemon 'evesyncd'
|
81
93
|
end
|
82
94
|
|
83
95
|
parser.on('-k', '--kill', 'Stop daemons') do
|
84
96
|
begin
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
rescue Errno::ESRCH => e
|
90
|
-
puts('Some process already killed')
|
97
|
+
kill_by_pid 'evemond'
|
98
|
+
kill_by_pid 'evehand'
|
99
|
+
kill_by_pid 'evesyncd'
|
100
|
+
kill_by_pid 'evedatad'
|
91
101
|
rescue StandardError => e
|
92
102
|
puts("Error: #{e}")
|
93
103
|
puts('Something went wrong while killing processes. Do it yourself!')
|
@@ -192,4 +202,5 @@ def evesync(opts)
|
|
192
202
|
end
|
193
203
|
end
|
194
204
|
|
205
|
+
|
195
206
|
evesync opts
|
data/lib/evesync/config.rb
CHANGED
@@ -8,6 +8,7 @@ module Evesync
|
|
8
8
|
class << self
|
9
9
|
|
10
10
|
DEFAULTS = {
|
11
|
+
'loglevel' => Constants::DEFAULT_LOGLEVEL,
|
11
12
|
'ntp' => '',
|
12
13
|
'evemond' => {
|
13
14
|
'port' => Constants::MOOND_PORT,
|
@@ -30,10 +31,8 @@ module Evesync
|
|
30
31
|
}
|
31
32
|
|
32
33
|
|
33
|
-
def [](
|
34
|
-
|
35
|
-
|
36
|
-
@@config[daemon.to_s]
|
34
|
+
def [](param)
|
35
|
+
config[param.to_s]
|
37
36
|
end
|
38
37
|
|
39
38
|
def reread
|
@@ -55,8 +54,9 @@ module Evesync
|
|
55
54
|
Log.info("Config initialized!")
|
56
55
|
end
|
57
56
|
|
58
|
-
def
|
59
|
-
! defined? @@config
|
57
|
+
def config
|
58
|
+
read_config if ! defined? @@config
|
59
|
+
@@config
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
data/lib/evesync/constants.rb
CHANGED
data/lib/evesync/err.rb
CHANGED
data/lib/evesync/ipc/data.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'drb/drb'
|
2
2
|
|
3
|
-
# TODO: add custom exceptions for IPCData
|
4
3
|
module Evesync
|
4
|
+
|
5
|
+
|
5
6
|
module IPCData
|
7
|
+
# TODO: add custom exceptions for IPCData
|
8
|
+
|
9
|
+
|
6
10
|
def self.pack(message)
|
7
11
|
unless message.respond_to? :to_hash
|
8
12
|
err_msg = "IPC ERROR Instance #{message} must implement `to_hash'"
|
data/lib/evesync/ipc/ipc.rb
CHANGED
data/lib/evesync/log.rb
CHANGED
@@ -2,8 +2,10 @@ require 'logger'
|
|
2
2
|
require 'evesync/config'
|
3
3
|
require 'evesync/constants'
|
4
4
|
|
5
|
-
|
5
|
+
|
6
6
|
module Evesync
|
7
|
+
|
8
|
+
# This module is responsible for logging
|
7
9
|
module Log
|
8
10
|
# Supported levels for logging
|
9
11
|
LEVELS = %i[debug info warn error fatal].freeze
|
data/lib/evesync/ntp.rb
CHANGED
@@ -1,11 +1,22 @@
|
|
1
1
|
require 'net/ntp'
|
2
|
+
require 'evesync/log'
|
2
3
|
require 'evesync/config'
|
3
4
|
|
4
5
|
module Evesync
|
5
6
|
module NTP
|
6
7
|
|
7
8
|
def self.time
|
8
|
-
|
9
|
+
begin
|
10
|
+
Timeout.timeout(5) do
|
11
|
+
Net::NTP.get(Config['ntp']).time
|
12
|
+
end
|
13
|
+
rescue Errno::ECONNREFUSED
|
14
|
+
Log.warn('NTP not configured. Using local time for timestamps')
|
15
|
+
Time.now
|
16
|
+
rescue Timeout::Error
|
17
|
+
Log.warn('NTP timeout. Using local time')
|
18
|
+
Time.now
|
19
|
+
end
|
9
20
|
end
|
10
21
|
|
11
22
|
def self.timestamp
|
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'evesync/log'
|
2
2
|
|
3
|
-
# Manages package manager things
|
4
|
-
# TODO: trigger package_watcher event to update database
|
5
3
|
module Evesync
|
6
4
|
module OS
|
5
|
+
|
6
|
+
##
|
7
|
+
# Manages package manager things
|
8
|
+
# TODO: trigger package_watcher event to update database
|
9
|
+
|
7
10
|
module PackageManager
|
8
11
|
class << self
|
9
12
|
def install(*args)
|
data/lib/evesync/trigger.rb
CHANGED
data/lib/evesync/watcher.rb
CHANGED
data/lib/evesync.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evesync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kiselev Valentine
|
@@ -108,7 +108,8 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 2.1.3
|
111
|
-
description: Daemons and utility for package and file changes synchronization.
|
111
|
+
description: Daemons and utility for package and file changes synchronization. Installation
|
112
|
+
requires ruby headers and build tools (make, gcc).'
|
112
113
|
email: mrexox@yahoo.com
|
113
114
|
executables:
|
114
115
|
- evemond
|
@@ -194,5 +195,6 @@ requirements: []
|
|
194
195
|
rubygems_version: 3.0.3
|
195
196
|
signing_key:
|
196
197
|
specification_version: 4
|
197
|
-
summary: Daemons and utility for package and file changes synchronization
|
198
|
+
summary: Daemons and utility for package and file changes synchronization. Installation
|
199
|
+
requires ruby headers and build tools (make, gcc).
|
198
200
|
test_files: []
|