Class: Fastlane::Actions::QueueStopAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/queue/actions/queue_stop_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



56
57
58
# File 'lib/fastlane/plugin/queue/actions/queue_stop_action.rb', line 56

def self.authors
  ["Josh Holtz"]
end

.available_optionsObject



68
69
70
# File 'lib/fastlane/plugin/queue/actions/queue_stop_action.rb', line 68

def self.available_options
  # No options right now
end

.descriptionObject



52
53
54
# File 'lib/fastlane/plugin/queue/actions/queue_stop_action.rb', line 52

def self.description
  "Stops web server and worker for queueing fastlane jobs"
end

.detailsObject



64
65
66
# File 'lib/fastlane/plugin/queue/actions/queue_stop_action.rb', line 64

def self.details
  "Stops a Resque web server and worker for queueing fastlane jobs"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/fastlane/plugin/queue/actions/queue_stop_action.rb', line 72

def self.is_supported?(platform)
  true
end

.return_valueObject



60
61
62
# File 'lib/fastlane/plugin/queue/actions/queue_stop_action.rb', line 60

def self.return_value
  # No return value right now
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fastlane/plugin/queue/actions/queue_stop_action.rb', line 4

def self.run(params)
  UI.message("Stopping the queue's web server and worker!")

  # I feel bad about this but need to kill the process of the worker
  # and shutdown the worker and prunce dead workers from showing
  # in the Resque web interface
  require 'resque'
  begin
    Resque::Worker.all.each do |worker|
      begin
        Process.kill("KILL", worker.pid)
      rescue StandardError
        true
      end
      worker.shutdown!
      worker.prune_dead_workers
    end
  rescue StandardError
    UI.warning("Nothing to stop")
  end

  # Shut down our web server
  Process.fork do
    begin
      require 'vegas'
      require 'resque/server'
      Vegas::Runner.new(Resque::Server, 'fastlane-plugin-queue-resque-web', {}, ["--kill"])
      puts "killed resque"
    rescue StandardError
      UI.warning("Nothing to stop")
    end
  end
  
  Process.fork do
    begin
      require 'vegas'
      require 'resque/server'
      Vegas::Runner.new(App, 'fastlane-plugin-queue-app', {}, ["--kill"])
      puts "killed app"
    rescue StandardError
      UI.warning("Nothing to stop")
    end
  end
  
  # Sleeping because we need time to kill these proceses ^ :-|
  sleep 5
end