Module: Capistrano::Influx
- Defined in:
- lib/capistrano/influx.rb,
lib/capistrano/influx/version.rb
Constant Summary collapse
- VERSION =
"0.3.0"
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
- #enabled_for_stage(stage, *enabled_stages) ⇒ Object
- #influx_deploy(app, branch, stage, deployer) ⇒ Object
Class Method Details
.extended(configuration) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/capistrano/influx.rb', line 43 def self.extended(configuration) configuration.load do after 'deploy', 'influx:store_deploy' set :deployer do ENV['SSHUSER'] || `git config user.name`.chomp end namespace :influx do task :store_deploy do if enabled_for_stage fetch(:stage, 'production'), fetch(:influx_stages, '') influx_deploy(fetch(:application), fetch(:branch), fetch(:stage, 'production'), fetch(:deployer)) end end end end end |
Instance Method Details
#connection ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/capistrano/influx.rb', line 8 def connection db = fetch(:influx_database) host = fetch(:influx_host, '127.0.0.1') port = fetch(:influx_port, 8086) user = fetch(:influx_user) pass = fetch(:influx_pass) @influxdb ||= InfluxDB::Client.new db, username: user, password: pass, host: host, port: port @influxdb end |
#enabled_for_stage(stage, *enabled_stages) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/capistrano/influx.rb', line 36 def enabled_for_stage(stage, *enabled_stages) enabled_stages.flatten.each do |s| return true if s == :all || stage == s end false end |
#influx_deploy(app, branch, stage, deployer) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/capistrano/influx.rb', line 22 def influx_deploy(app, branch, stage, deployer) conn = connection name = fetch(:influx_series) data = { user: deployer, project: app, version: branch, environment: stage, title: "#{app} #{branch}", description: "#{deployer} deployed #{app} #{branch} to #{stage} successfully" } conn.write_point(name, data) end |