Class: Fastlane::Actions::QueueStartAction

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

Class Method Summary collapse

Class Method Details

.authorsObject



37
38
39
# File 'lib/fastlane/plugin/queue/actions/queue_start_action.rb', line 37

def self.authors
  ["Josh Holtz"]
end

.available_optionsObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/fastlane/plugin/queue/actions/queue_start_action.rb', line 49

def self.available_options
  # No options right now but probably allow Resque options to be set
  [
    # FastlaneCore::ConfigItem.new(key: :your_option,
    #                         env_name: "QUEUE_YOUR_OPTION",
    #                      description: "A description of your option",
    #                         optional: false,
    #                             type: String)
  ]
end

.descriptionObject



33
34
35
# File 'lib/fastlane/plugin/queue/actions/queue_start_action.rb', line 33

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

.detailsObject



45
46
47
# File 'lib/fastlane/plugin/queue/actions/queue_start_action.rb', line 45

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


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

def self.is_supported?(platform)
  true
end

.return_valueObject



41
42
43
# File 'lib/fastlane/plugin/queue/actions/queue_start_action.rb', line 41

def self.return_value
  # This action will NEVER return because the worker is blocking
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
# File 'lib/fastlane/plugin/queue/actions/queue_start_action.rb', line 4

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

  # Gotta do the fork thing
  # Otherwise this process will block the worker from starting
  # This can get called  multiple times and only one server will be run
  Process.fork do
    require 'vegas'
    require 'resque/server'
    Vegas::Runner.new(Resque::Server, 'fastlane-plugin-queue-resque-web', {port: 5678, skip_launch: true})
  end
  
  Process.fork do
    require 'vegas'
    require 'resque/server'
    Vegas::Runner.new(App, 'fastlane-plugin-queue-app', {port: 5679})
  end

  # Starts a blocking worker
  require 'resque'
  worker = Resque::Worker.new("fastlane")
  worker.prepare
  worker.log "Starting worker #{self}"
  worker.work(5) # interval, will block

  # Stops the queue and webserver
  other_action.queue_stop
end