eventhub-command 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c253f8e84ba12dc215b82ee40d0818a6d50f525
4
- data.tar.gz: 59231b7c8a024d72664bcbc64bc446c7b4b71f11
3
+ metadata.gz: c2fb2bc5d80dcd69973bcbf48295c7b61e2fe17d
4
+ data.tar.gz: f6a9bda4684ef2222599b282d2ad30b09bfafca4
5
5
  SHA512:
6
- metadata.gz: 3aeb89f814a1f10bba9e17ed743b39aabb987ce3998f22896e5d7417f0764e59fb62a543c80dbd08ffa72c6193dca5c24fd655d35dde2584db63fefbda98fe9f
7
- data.tar.gz: a781e749277cd6d23d58f5d65af5bbc6b6bf810c86017e9aae1efec7db0062ac3d53f20898126e88c7f9432e31751f819c48bd843b4d98282ea5979276c9b1c0
6
+ metadata.gz: 38136338d0c5f426c3f7b3c01ce90dcf1e8ad9d2fee5d216832f5da80da627eb61cbd8736b3258d09c697059d8369d9ea02c16019f29b214de8ad6d770358f71
7
+ data.tar.gz: 7d51d14fe77a30d58c49a859cf65e13e84d58dca2fcf7483c7b84b0a1c9b583c0cab0ea5630266d7b937af12402c60a0dcf94aa96c9fad7c6c201d2b3b52b3df
@@ -0,0 +1,45 @@
1
+ class Deployer::ConsoleDeployer < Deployer::BaseDeployer
2
+
3
+ def deploy!
4
+ case deploy_via
5
+ when 'scp' then deploy_via_scp
6
+ when 'svn' then deploy_via_svn
7
+ else raise "Unknown value for deploy_via: #{deploy_via}"
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def working_dir
14
+ options[:working_dir]
15
+ end
16
+
17
+ def deploy_via_scp
18
+ cmd = "cd #{working_dir} && bundle install && bundle exec cap #{stage.name} deploy"
19
+ execute_in_clean_env(cmd)
20
+ end
21
+
22
+ def deploy_via_svn
23
+ console_release_zip = '~/apps/event_hub/shared/cached_copy_svn/branches/master/releases/rails/console.zip'
24
+ cmds = []
25
+ cmds << "rm -rf /tmp/console_deployment && mkdir -p /tmp/console_deployment"
26
+ cmds << "cd /tmp/console_deployment && unzip #{console_release_zip} -d ."
27
+ cmds << "cd /tmp/console_deployment/console && bundle install && bundle exec cap #{stage.name} deploy"
28
+ # run the command only on one host of this stage.
29
+ Deployer::Executor.new(stage.single_host_stage, verbose: verbose?) do |executor|
30
+ update_scm(executor)
31
+ cmds.each do |cmd|
32
+ executor.execute(cmd)
33
+ end
34
+ end
35
+ end
36
+
37
+ def execute_in_clean_env(cmd)
38
+ puts "Will run #{cmd} on your local machine"
39
+ Bundler.with_clean_env do
40
+ system cmd
41
+ end
42
+ end
43
+
44
+
45
+ end
@@ -0,0 +1,14 @@
1
+ desc 'deploy the console rails app'
2
+
3
+ command :deploy_console do |c|
4
+ c.flag([:stage], desc: 'stage', type: String, long_desc: 'Stage where processor is deployed to', default_value: 'development')
5
+ c.flag([:branch], desc: 'branch', type: String, long_desc: 'What branch to deploy. Only when deploy_via=scm', default_value: 'master')
6
+ c.flag([:tag], desc: 'tag', type: String, long_desc: 'What tag to deploy. Only when deploy_via=scm', default_value: nil)
7
+ c.flag([:deploy_via], desc: 'where to deploy from', type: String, long_desc: 'deploy via scm or scp. If you use scp then the working_dir is packaged and copied tot the servers', default_value: 'svn')
8
+ c.flag([:working_dir], desc: 'directory to execute commands in', type: String, default_value: '.')
9
+ c.switch([:v, :verbose], :desc => 'Show additional output.')
10
+
11
+ c.action do |global_options, options, args|
12
+ Deployer::ConsoleDeployer.new(options).deploy!
13
+ end
14
+ end
@@ -0,0 +1,59 @@
1
+ desc "manage repositories"
2
+
3
+ command :dump do |command|
4
+ command.desc "Create a backup"
5
+ command.flag([:stage], desc: 'stage', type: String, long_desc: 'Stage where processor is deployed to', default_value: 'development')
6
+ command.switch([:v, :verbose], :desc => 'Show additional output.')
7
+
8
+ command.command :download do |command|
9
+
10
+ command.action do |global_options, options, args|
11
+ source = File.join('/tmp', "dump-#{args[0]}.zip")
12
+ target = File.join('/tmp', "dump-#{args[0]}.zip")
13
+ dir = File.join('/tmp', "dump-#{args[0]}")
14
+
15
+ cmds = []
16
+ host = stage(options).single_host_stage.hosts[0]
17
+
18
+ system "scp -P #{host[:port]} #{host[:user]}@#{host[:host]}:#{source} #{target}"
19
+ system "unzip -d #{dir} #{target}"
20
+ puts "Downloaded dump to #{target} and extracted to #{dir.green}"
21
+ end
22
+ end
23
+
24
+ command.command :create do |command|
25
+
26
+ command.action do |global_options, options, args|
27
+ stamp = Time.now.strftime("%Y%m%d-%H%M%S")
28
+ dir = File.join('/tmp', "dump-#{stamp}")
29
+ zip_target = File.join('/tmp', "dump-#{stamp}.zip")
30
+ logstash_source = '~/apps/event_hub/shared/logs/logstash_output.log'
31
+ cmds = []
32
+ cmds << "mkdir -p #{dir}"
33
+ cmds << "cd #{dir} && pg_dump -Uevent_hub_console event_hub_console > console_pg.sql"
34
+ cmds << "if [[ -d #{logstash_source} ]] ; then cp #{logstash_source} #{File.join(dir, 'logstash_output.log')} ; fi"
35
+ cmds << "cd #{dir} && zip -r #{zip_target} ."
36
+ cmds << "rm -rf #{dir}"
37
+
38
+
39
+ Deployer::Executor.new(stage(options).single_host_stage, verbose: options[:verbose]) do |executor|
40
+ cmds.each do |cmd|
41
+ executor.execute(cmd)
42
+ end
43
+ end
44
+
45
+
46
+ puts "Created an dump in #{zip_target}. Use #{stamp.green} as identifier for eh dump download."
47
+ end
48
+ end
49
+
50
+
51
+ private
52
+
53
+ def stage(options)
54
+ @stage ||= begin
55
+ stage_path = File.join(Eh::Settings.current.stages_dir, "#{options[:stage]}.yml")
56
+ Deployer::Stage.load(options[:stage], stage_path)
57
+ end
58
+ end
59
+ end
data/lib/eh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eh
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventhub-command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pascal Betz
@@ -145,6 +145,7 @@ files:
145
145
  - lib/deployer.rb
146
146
  - lib/deployer/base_deployer.rb
147
147
  - lib/deployer/config_deployer.rb
148
+ - lib/deployer/console_deployer.rb
148
149
  - lib/deployer/executor.rb
149
150
  - lib/deployer/mule_deployer.rb
150
151
  - lib/deployer/net_ssh_extension.rb
@@ -153,8 +154,10 @@ files:
153
154
  - lib/eh-commands.rb
154
155
  - lib/eh.rb
155
156
  - lib/eh/commands/deploy_config.rb
157
+ - lib/eh/commands/deploy_console.rb
156
158
  - lib/eh/commands/deploy_mule.rb
157
159
  - lib/eh/commands/deploy_ruby.rb
160
+ - lib/eh/commands/dump.rb
158
161
  - lib/eh/commands/generate_processor.rb
159
162
  - lib/eh/commands/list_stages.rb
160
163
  - lib/eh/commands/package_ruby.rb