Class: Euston::Daemons::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/euston-daemons/rake_task.rb

Direct Known Subclasses

PipelineRakeTask

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, name = :euston_daemon) {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Yields:

  • (_self)

Yield Parameters:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/euston-daemons/rake_task.rb', line 34

def initialize environment, name = :euston_daemon
  @name = name
  @log_filename = @pid_filename = name.to_s.gsub(/_/, '-')
  @verbose = true
  @environment = validate_environment environment
  @data = { :environment => @environment }

  yield self if block_given?
  send :before_creating_task if respond_to? :before_creating_task

  desc("Run a Euston daemon") unless ::Rake.application.last_comment
  task name do
    RakeFileUtils.send(:verbose, verbose) do
      load_daemon_config_file
      initialize_logger
      initialize_settings
      write_pid_file
      log_startup
      env = load_environment
      post_setup_callback.call env unless post_setup_callback.nil?
      launch_and_wait_for_exit
      log_shutdown
      remove_pid_file
    end
  end
end

Instance Attribute Details

#bundler_groupsObject

Bundler groups. Can be a single symbol or an array of symbols.



13
14
15
# File 'lib/euston-daemons/rake_task.rb', line 13

def bundler_groups
  @bundler_groups
end

#daemon_classObject

Daemon class. Must be supplied as a string.



16
17
18
# File 'lib/euston-daemons/rake_task.rb', line 16

def daemon_class
  @daemon_class
end

#log_filenameObject

Defaults to the task name with underscores converted to dashes



22
23
24
# File 'lib/euston-daemons/rake_task.rb', line 22

def log_filename
  @log_filename
end

#nameObject

Name of task.

default:

:daemon


10
11
12
# File 'lib/euston-daemons/rake_task.rb', line 10

def name
  @name
end

#pid_filenameObject

Defaults to the task name with underscores converted to dashes



25
26
27
# File 'lib/euston-daemons/rake_task.rb', line 25

def pid_filename
  @pid_filename
end

#post_setup_callbackObject

Callable. Receives the daemon environment object to allow the user to perform other related config operations.



19
20
21
# File 'lib/euston-daemons/rake_task.rb', line 19

def post_setup_callback
  @post_setup_callback
end

#verboseObject

Use verbose output. If this is set to true, the task will print the executed command to stdout.

default:

true


32
33
34
# File 'lib/euston-daemons/rake_task.rb', line 32

def verbose
  @verbose
end