six-updater-web 0.20.7 → 0.20.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/testtask'
7
7
 
8
8
  spec = Gem::Specification.new do |s|
9
9
  s.name = 'six-updater-web'
10
- s.version = '0.20.7'
10
+ s.version = '0.20.8'
11
11
  s.has_rdoc = false
12
12
  #s.extra_rdoc_files = ['README', 'LICENSE']
13
13
  s.summary = 'Your summary here'
@@ -146,7 +146,7 @@ class Appsetting < ActiveRecord::Base
146
146
  end
147
147
 
148
148
  def processes
149
- Six::Appmanager.find_process(process_name)
149
+ Six::Appmanager.find_process(process_name, self.real_path)
150
150
  end
151
151
 
152
152
  def read_logfile
@@ -154,7 +154,7 @@ class Appsetting < ActiveRecord::Base
154
154
  end
155
155
 
156
156
  def kill!
157
- Six::Appmanager.kill_by_name(process_name)
157
+ Six::Appmanager.kill_by_name(process_name, self.real_path)
158
158
  end
159
159
 
160
160
  def rpt
@@ -22,7 +22,7 @@ case RUBY_VERSION
22
22
  end
23
23
 
24
24
  module SixUpdaterWeb
25
- VERSION = "0.20.7"
25
+ VERSION = "0.20.8"
26
26
  COMPONENT = "six-updater-web"
27
27
 
28
28
  DEFAULT_IP = "127.0.0.1" unless defined?(DEFAULT_IP)
@@ -48,16 +48,44 @@ module Six
48
48
 
49
49
  # TODO: Kill by ... multiple properties. gamefolder, etc.
50
50
 
51
- def kill_by_name(name)
52
- find_process(name).each { |process| kill(process) }
51
+ def kill_by_name(name, path = nil)
52
+ find_process(name, path).each { |process| kill(process) }
53
53
  end
54
54
 
55
- def find_process(name)
55
+ def find_process(name, path)
56
56
  pids = []
57
+ logger.info "Checking for #{name} - #{path}"
57
58
 
58
59
  begin
59
60
  case RUBY_PLATFORM
60
61
  when /-mingw32$/, /-mswin32$/
62
+ %x[WMIC PROCESS get Caption,ExecutablePath,ProcessId].each_line do |l| #Commandline
63
+ line = l.clone
64
+ line.chomp!
65
+ line.strip!
66
+ reg = /([0-9]*)$/
67
+ line[reg]
68
+ pid = $1
69
+ line.sub!(reg, "")
70
+ line.strip!
71
+ line[/^([\w ]*\.\w*)[ ]*(.*)/]
72
+ image, full = $1, $2
73
+ next if image.nil?
74
+
75
+ case image.downcase
76
+ when name.downcase
77
+ unless path && !full.nil?
78
+ pids << pid
79
+ next
80
+ end
81
+ logger.info File.join(path, name).sub("/", "\\").downcase
82
+ logger.info full.downcase
83
+ if File.join(path, name).sub("/", "\\").downcase == full.downcase
84
+ pids << pid
85
+ end
86
+ end
87
+ end
88
+ =begin
61
89
  out = %x[tasklist]
62
90
  out.split("\n").each do |line|
63
91
  if line =~ /\A#{name}[\t| ]*([0-9]*)/
@@ -68,7 +96,11 @@ module Six
68
96
  end
69
97
  end
70
98
  end
99
+ =end
71
100
  else
101
+ # TODO: Include exe/cmdnline check;
102
+ # /proc/PID/exe
103
+ # /proc/PID/cmdline
72
104
  %x[ps -A | grep #{name}].split("\n").each do |line|
73
105
  unless line[/grep/]
74
106
  line[/^\s*([0-9]*)/]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 20
8
- - 7
9
- version: 0.20.7
8
+ - 8
9
+ version: 0.20.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sickboy