sqs_image_processor 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c4e61adf1c5d48f2606df7964d4ed1a0ba765089
4
- data.tar.gz: 852021f5d287a612a5b8e24fc28c27c37ed511e7
3
+ metadata.gz: b2fc3e6370c83e9ce6ade54d4a54e521b4eeede6
4
+ data.tar.gz: 17c29df5395fe1b7d5a411d9a543c28348a0d35c
5
5
  SHA512:
6
- metadata.gz: 36d80e0c3b592d91bd82a75594f0c1ee12ae92a0fdc84efb0c14db71017b7d9c604a3207bb8b7e09ee03862d29a11154dd8eec60651436dd196c1a7b01403506
7
- data.tar.gz: ad3f55a9626ca737834dc0d773623bfc446a92ff40611af0dd6e3fbb3294c4c5e977151950b5859328efbf66e8fe111656a5d40c6b5b3c4bb549eb66342e46c9
6
+ metadata.gz: 8bc846e3dcb1e088ef1822dc2fb47b7efbed6912018edf0fa98754a0dfe1765b536489b17e26124fe7c3a55a940597ee09fdf91ad059be92ea9080ab88218d73
7
+ data.tar.gz: 8261300d8873be57090d4b5b38af75e6aeaa91d420a640b934044514ba58a81b26122132aba7d9bb92183ec5dbb8eb2c5f7c1a1a19d79dac4934220b399ebf31
@@ -22,6 +22,7 @@ module SqsImageProcessor
22
22
  def start
23
23
  config_path = options[:c]
24
24
  daemonize = options[:d]
25
+ child_pids = []
25
26
 
26
27
  if !File.exists?(config_path)
27
28
  puts "Error: Config file not found."
@@ -33,7 +34,12 @@ module SqsImageProcessor
33
34
  config = SqsImageProcessor::Config.load( config_path )
34
35
  puts "Loaded config file at #{config_path}."
35
36
  puts "Starting SQS Image Processor."
36
- SqsImageProcessor::Worker.start( config )
37
+ 4.times do
38
+ fork do
39
+ SqsImageProcessor::Worker.start( config )
40
+ end
41
+ end
42
+ Process.waitall
37
43
  end
38
44
  end
39
45
 
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module SqsImageProcessor
2
4
  module ProcessManager
3
5
  def self.pid_is_running?( pid )
@@ -13,6 +15,13 @@ module SqsImageProcessor
13
15
  if self.is_running?
14
16
  pid = File.open("/tmp/sqs_image_processor_manager.pid", 'a+') {|f| f.read }.to_i
15
17
  Process.kill("KILL", pid)
18
+ Dir.foreach('/tmp/sqs_image_processor_manager') do |item|
19
+ next if item == '.' or item == '..'
20
+ begin
21
+ Process.kill("KILL", item.gsub('.pid','').to_i)
22
+ rescue
23
+ end
24
+ end
16
25
  puts "Stopped instance of SqsImageProcessor."
17
26
  else
18
27
  puts "Error: SqsImageProcessor isn't running."
@@ -29,11 +38,18 @@ module SqsImageProcessor
29
38
  end
30
39
 
31
40
  def self.generate_pid_file
41
+ FileUtils.mkdir_p '/tmp/sqs_image_processor_manager'
32
42
  File.open("/tmp/sqs_image_processor_manager.pid", 'w') {|f|
33
43
  f.write(Process.pid)
34
44
  }
35
45
  end
36
46
 
47
+ def self.generate_child_pid_file( pid )
48
+ File.open("/tmp/sqs_image_processor_manager/#{pid}.pid", 'w') {|f|
49
+ f.write(pid)
50
+ }
51
+ end
52
+
37
53
  def self.get_pid
38
54
  pid = File.open("/tmp/sqs_image_processor_manager.pid", 'a+') {|f| f.read }.to_i
39
55
  end
@@ -1,3 +1,3 @@
1
1
  module SqsImageProcessor
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -4,6 +4,7 @@ require 'uri'
4
4
  module SqsImageProcessor
5
5
  module Worker
6
6
  def self.start( config )
7
+ SqsImageProcessor::ProcessManager.generate_child_pid_file(Process.pid)
7
8
  continue_processing = true
8
9
 
9
10
  sqs_client = Aws::SQS::Client.new(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sqs_image_processor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neil Turner