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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89f74020a22ae230f9ff9d31d26a7983acde3cc073a4ef9e70e6f053d028e91f
4
- data.tar.gz: 593bfa7b50fd6a2f17818cb00a9e1394c3409808c724469bc3bad706ead0e4ff
3
+ metadata.gz: 2dfabc12dbd6228ae7855ffd195a96ebc4b2c9c2164e477d41eed688f9b4bac2
4
+ data.tar.gz: 2888ea5a7979af4fe27b519c864e57867d08f74bf5a1f44704eb90b9b49c6f1a
5
5
  SHA512:
6
- metadata.gz: 596d803d35d866764391284a1c65eead4e73d7ab7a73304d5d7f4b6275943988b829b340f87b676f3fc8aef99b589df2a5bbbd42297a22e577edaf4839a0f4c7
7
- data.tar.gz: 5520247054b67b98b9753c07bf50ef099ea01e3f9777beaf23cbf0a2cf9947022e50e274ebb6c5bdebccde17c779361797d31b3d8acdb8f00c0afcbb90109f2d
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("evesync-#{VERSION}")
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
- r, w = IO.pipe
72
- data_pid = spawn('evedatad', :err => '/var/log/evesync/evedatad.log', :out=>:err)
73
- mon_pid = spawn('evemond', :err => '/var/log/evesync/evemond.log', :out=>:err)
74
- hand_pid = spawn('evehand', :err => '/var/log/evesync/evehand.log', :out=>:err)
75
- sync_pid = spawn('evesyncd', :err => '/var/log/evesync/evesyncd.log', :out=>:err)
76
- FileUtils.mkdir_p('/var/run/evesync')
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
- Process.kill('TERM', File.read('/var/run/evesync/evemond.pid').to_i)
86
- Process.kill('TERM', File.read('/var/run/evesync/evehand.pid').to_i)
87
- Process.kill('TERM', File.read('/var/run/evesync/evesyncd.pid').to_i)
88
- Process.kill('TERM', File.read('/var/run/evesync/evedatad.pid').to_i)
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
@@ -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 [](daemon)
34
- read_config if needs_reading
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 needs_reading
59
- ! defined? @@config
57
+ def config
58
+ read_config if ! defined? @@config
59
+ @@config
60
60
  end
61
61
  end
62
62
  end
@@ -9,7 +9,7 @@ module Evesync
9
9
  DB_PATH = '/var/lib/evesync/db/'.freeze
10
10
  DB_FILES_PATH = '/var/lib/evesync/files/'.freeze
11
11
 
12
- DEFAULT_LOGLEVEL = 'debug'.freeze
12
+ DEFAULT_LOGLEVEL = 'info'.freeze
13
13
 
14
14
  DISCOVER_TIMEOUT = 3600
15
15
  WATCH_INTERVAL = 2
data/lib/evesync/err.rb CHANGED
@@ -1,5 +1,8 @@
1
- # TODO: move to a err directory
1
+
2
2
  module Evesync
3
+ # TODO: move to a err directory
4
+
5
+
3
6
  module Err
4
7
 
5
8
  # Base Evesync error class.
@@ -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'"
@@ -1,9 +1,9 @@
1
1
  require 'evesync/config'
2
2
 
3
3
  module Evesync
4
- #
4
+ ##
5
5
  # Constants and helpful functions for Evesync::IPC module.
6
- #
6
+
7
7
  module IPC
8
8
  $SAFE = 1 # 'no eval' rule
9
9
 
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
- # This module is responsible for logging
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
- Net::NTP.get(Config['ntp']).time
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,6 +1,8 @@
1
1
  module Evesync
2
2
  module OS
3
3
  # FIXME: pacman downgrading requires full url path
4
+
5
+
4
6
  module PackageManager
5
7
  class << self
6
8
  def install(*args)
@@ -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)
@@ -22,6 +22,7 @@ module Evesync
22
22
  db: evedatad,
23
23
  remotes: @remote_handlers
24
24
  )
25
+
25
26
  file_trigger = Trigger::File.new(
26
27
  db: evedatad,
27
28
  remotes: @remote_handlers
@@ -1,6 +1,5 @@
1
1
  require 'timeout'
2
2
  require 'evesync/log'
3
- require 'evesync/config'
4
3
  require 'evesync/ipc/client'
5
4
  require 'evesync/watcher/file'
6
5
  require 'evesync/watcher/package'
data/lib/evesync.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Evesync
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '1.0.5'.freeze
3
3
  end
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
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: []