Module: Deployinator

Defined in:
lib/deployinator.rb,
lib/deployinator/app.rb,
lib/deployinator/plugin.rb,
lib/deployinator/helpers.rb,
lib/deployinator/logging.rb,
lib/deployinator/version.rb,
lib/deployinator/controller.rb,
lib/deployinator/helpers/dsh.rb,
lib/deployinator/helpers/git.rb,
lib/deployinator/helpers/view.rb,
lib/deployinator/views/layout.rb,
lib/deployinator/helpers/deploy.rb,
lib/deployinator/helpers/plugin.rb,
lib/deployinator/helpers/version.rb,
lib/deployinator/helpers/stack-tail.rb,
lib/deployinator/plugins/delete_log.rb,
lib/deployinator/helpers/concurrency.rb

Overview

This plugin enables deploys to optionally delete the log file they just generated.

Add the plugin to the stack as you normally would (either globally, or for that stack specifically). And modify the return hash of the deploy method to include a truthy value for :should_delete_log

A great usecase for this functionality is with a 'cron deploy'. Imagine you have a deploy that spins up every minute and checks whether it needs to actually perform an action or not. The vast majority of the time, the deploy has nothing to do and generates an empty log. In those cases, you KNOW that the deploy has nothing to do. So you tell the plugin to delete the log as not to clutter your Deployinator host with thousands of empty log files as compared to only a few with actual actions.

Defined Under Namespace

Modules: Helpers, Views Classes: Controller, DeleteLog, Deploy, DeployinatorApp, Plugin, StackDowntimeInfo

Constant Summary collapse

VERSION =
"1.1.1"
@@stats_renamed_stacks =
[]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.admin_groupsObject

Returns the value of attribute admin_groups


60
61
62
# File 'lib/deployinator.rb', line 60

def admin_groups
  @admin_groups
end

.app_contextObject

a hash for context specifics settings (test,dev,production) of deployinator itself


33
34
35
# File 'lib/deployinator.rb', line 33

def app_context
  @app_context
end

.default_userObject

Default username for passwordless ssh


23
24
25
# File 'lib/deployinator.rb', line 23

def default_user
  @default_user
end

.deploy_controllerObject

the controller class. defaults to Deployinator::Controller if you override this it should be a subclass of Deployinator::Controller


69
70
71
# File 'lib/deployinator.rb', line 69

def deploy_controller
  @deploy_controller
end

.deploy_hostObject

Deploy Host


42
43
44
# File 'lib/deployinator.rb', line 42

def deploy_host
  @deploy_host
end

.disabled_stacksObject

Returns the value of attribute disabled_stacks


89
90
91
# File 'lib/deployinator.rb', line 89

def disabled_stacks
  @disabled_stacks
end

.domainObject

Your company domain name


14
15
16
# File 'lib/deployinator.rb', line 14

def domain
  @domain
end

.git_info_for_stackObject

Git info per stack


39
40
41
# File 'lib/deployinator.rb', line 39

def git_info_for_stack
  @git_info_for_stack
end

.git_sha_lengthObject

Returns the value of attribute git_sha_length


50
51
52
# File 'lib/deployinator.rb', line 50

def git_sha_length
  @git_sha_length
end

.github_hostObject

Default github_host


26
27
28
# File 'lib/deployinator.rb', line 26

def github_host
  @github_host
end

.global_pluginsObject

Returns the value of attribute global_plugins


52
53
54
# File 'lib/deployinator.rb', line 52

def global_plugins
  @global_plugins
end

.help_urlObject

Link to a help page


20
21
22
# File 'lib/deployinator.rb', line 20

def help_url
  @help_url
end

.hostnameObject

Hostname where deployinator runs


17
18
19
# File 'lib/deployinator.rb', line 17

def hostname
  @hostname
end

.index_view_classObject

Default Index View Class


81
82
83
# File 'lib/deployinator.rb', line 81

def index_view_class
  @index_view_class
end

.invisible_stacksObject

Returns the value of attribute invisible_stacks


87
88
89
# File 'lib/deployinator.rb', line 87

def invisible_stacks
  @invisible_stacks
end

.issue_trackerObject

Bug or issue tracker - proc that takes the issue id as an argument ex: Deployinator.issue_tracker = proc {|issue| “foo/browse/#{issue}”}


30
31
32
# File 'lib/deployinator.rb', line 30

def issue_tracker
  @issue_tracker
end

.log_fileObject

File to log to


11
12
13
# File 'lib/deployinator.rb', line 11

def log_file
  @log_file
end

.log_pathObject

Log path


48
49
50
# File 'lib/deployinator.rb', line 48

def log_path
  @log_path
end

.maintenance_contactObject

Returns the value of attribute maintenance_contact


65
66
67
# File 'lib/deployinator.rb', line 65

def maintenance_contact
  @maintenance_contact
end

.maintenance_modeObject

Returns the value of attribute maintenance_mode


63
64
65
# File 'lib/deployinator.rb', line 63

def maintenance_mode
  @maintenance_mode
end

.root_dirObject

Your install root


36
37
38
# File 'lib/deployinator.rb', line 36

def root_dir
  @root_dir
end

.stack_pluginsObject

Returns the value of attribute stack_plugins


54
55
56
# File 'lib/deployinator.rb', line 54

def stack_plugins
  @stack_plugins
end

.stack_tailer_portObject

Returns the value of attribute stack_tailer_port


56
57
58
# File 'lib/deployinator.rb', line 56

def stack_tailer_port
  @stack_tailer_port
end

.stack_tailer_websocket_portObject

Returns the value of attribute stack_tailer_websocket_port


58
59
60
# File 'lib/deployinator.rb', line 58

def stack_tailer_websocket_port
  @stack_tailer_websocket_port
end

.stats_extra_grepObject

filter log entries in /stats


78
79
80
# File 'lib/deployinator.rb', line 78

def stats_extra_grep
  @stats_extra_grep
end

.stats_ignored_stacksObject

exclude stacks in /stats, even if present in stats_included_stacks


75
76
77
# File 'lib/deployinator.rb', line 75

def stats_ignored_stacks
  @stats_ignored_stacks
end

.stats_included_stacksObject

include stacks in /stats


72
73
74
# File 'lib/deployinator.rb', line 72

def stats_included_stacks
  @stats_included_stacks
end

.stats_renamed_stacksObject

list of configurations for grouping historical / renamed stacks in /stats


84
85
86
# File 'lib/deployinator.rb', line 84

def stats_renamed_stacks
  @stats_renamed_stacks
end

.timing_log_pathObject

Timing Log path


45
46
47
# File 'lib/deployinator.rb', line 45

def timing_log_path
  @timing_log_path
end

Class Method Details

.envObject

Running environment for deployinator This is taken from RACK_ENV or RAILS_ENV note this is different from deployinator's concept of stacks/environments


121
122
123
# File 'lib/deployinator.rb', line 121

def env
  ENV["RACK_ENV"] || ENV["RAILS_ENV"] || "development"
end

.get_stack_filesObject

Gets all the stack files in the stack directory


126
127
128
# File 'lib/deployinator.rb', line 126

def get_stack_files
  Dir[Deployinator.root(["stacks", "*.rb"])]
end

.get_stacksObject

Gets all the stack names without the .rb extension


131
132
133
134
135
# File 'lib/deployinator.rb', line 131

def get_stacks
  self.get_stack_files.sort.map do |file|
    File.basename(file, ".rb")
  end
end

.get_visible_stacksObject


137
138
139
140
141
142
# File 'lib/deployinator.rb', line 137

def get_visible_stacks
  invisible = self.invisible_stacks.map(&:to_s)

  # array subtraction
  self.get_stacks - invisible
end

.initializeObject


91
92
93
94
95
# File 'lib/deployinator.rb', line 91

def initialize
  @stack_plugins = {}
  @global_plugins = []
  @admin_groups = []
end

.log_file?Boolean

is a log file defined?

Returns:

  • (Boolean)

106
107
108
# File 'lib/deployinator.rb', line 106

def log_file?
  log_file
end

.log_path?Boolean

Returns:

  • (Boolean)

110
111
112
# File 'lib/deployinator.rb', line 110

def log_path?
  log_path
end

.root(path = nil) ⇒ Object

Base root path Takes an optional argument of a string or array and returns the path(s) From the root of deployinator


100
101
102
103
# File 'lib/deployinator.rb', line 100

def root(path = nil)
  base = Deployinator.root_dir
  path ? File.join(base, path) : base
end

.setup_loggingObject


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/deployinator/logging.rb', line 2

def self.setup_logging
  if Deployinator.log_file?
    $deployinator_log_handle = File.new(Deployinator.log_file, "a")
    def $stdout.write(string)
      $deployinator_log_handle.write string
      super
    end
    $stdout.sync = true
    $stderr.reopen($deployinator_log_handle)
    puts "Logging #{Deployinator.log_file}"
  end

  if Deployinator.log_path?
    $deployinator_log_path = File.new(Deployinator.log_path, "a")
  end

  if Deployinator.timing_log_path?
    $deployinator_timing_log_path = File.new(Deployinator.timing_log_path, "a")
  end

end

.timing_log_path?Boolean

Returns:

  • (Boolean)

114
115
116
# File 'lib/deployinator.rb', line 114

def timing_log_path?
  timing_log_path
end