lbhrr 1.0.14 → 1.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/exe/lbhrr +67 -23
  3. data/lib/lbhrr/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25e90a2b243aace3a947a0eff39b02f2c26bba159108b901ffbbb90027cb647a
4
- data.tar.gz: d2eb572f8a1310a2c23f5c7e1bc760283c21a023da56e06f879394dfb7526b3c
3
+ metadata.gz: 4672124c05861a59b6c7a12afbdf25563b15ecc15c698fe77e0a4c4de23f8f61
4
+ data.tar.gz: 6cc0597a46d143e69f870467d1003ae5986cb62d808e157fe2467e3c37a78705
5
5
  SHA512:
6
- metadata.gz: 95fe5d60e5b94f0e7a08eb32543a555d24595d87f56e8ace942bb96701e6657cda2796b4ec868a50430b5b645893e9277854bff143d34074d85297c4169deb40
7
- data.tar.gz: f202266c171819ae6ef96a2b12483615eb4c0a06a988f1b34770f60deacc8cb066eb629c41af0bdf232ecfb9e22c1a7336688c0d65be8dccbfab3a22593c3731
6
+ metadata.gz: 72c0ae593f56228adea25476e52ad041a2a6dc47eb11b1286a4507cb3d102814c7be8c34f1da3ad22f6529747d8dc080f5d95acbef242cf97eb3310a3e84eeb1
7
+ data.tar.gz: e535024b2126c1f5f0acdd11b676317cc5001db417875d81b5414bcbf205e5f92e534eb5679252a054a9b2196bba5689f1bb8adc3e49e6d0721d0b158176a757
data/exe/lbhrr CHANGED
@@ -3,6 +3,11 @@ require_relative "../lib/lbhrr"
3
3
 
4
4
  class LbhrrCLI < Thor
5
5
  no_commands do
6
+
7
+ def manifest?
8
+ File.join(Dir.pwd, "config","manifest.yml")
9
+ end
10
+
6
11
  def package
7
12
  # Load configuration
8
13
  config = load_configuration
@@ -100,7 +105,7 @@ class LbhrrCLI < Thor
100
105
  run_file_path = File.join(Dir.pwd, "exe", "run")
101
106
  run_file_content = "#!/bin/sh\n HARBR_ENV=$2 bundle exec puma -p $1"
102
107
  exe_directory = File.join(Dir.pwd, "exe")
103
-
108
+
104
109
  Dir.mkdir(exe_directory) unless Dir.exist?(exe_directory)
105
110
  File.write(run_file_path, run_file_content)
106
111
  File.chmod(0o755, run_file_path) # Set executable permission
@@ -134,14 +139,17 @@ class LbhrrCLI < Thor
134
139
 
135
140
  # Ensure local configuration exists
136
141
  unless File.exist?(local_config_path)
137
- FileUtils.mkdir_p(File.dirname(local_config_path)) unless Dir.exist?(File.dirname(local_config_path))
138
- File.write(local_config_path, create_example_local_config)
139
142
  end
140
143
 
141
144
  # Load and merge configurations
142
145
  global_config = YAML.load_file(global_config_path) || {}
143
- local_config = YAML.load_file(local_config_path) || {}
144
- global_config.merge(local_config)
146
+
147
+ if File.exist? local_config_path
148
+ local_config = YAML.load_file(local_config_path) || {}
149
+ global_config.merge(local_config)
150
+ end
151
+
152
+ global_config
145
153
  end
146
154
 
147
155
  def increment_version(manifest_path, current_version)
@@ -166,7 +174,7 @@ class LbhrrCLI < Thor
166
174
  local_config = YAML.load_file(local_config_path) || {}
167
175
  create_gitignore
168
176
  create_run_file
169
-
177
+
170
178
 
171
179
  # Include other initialization tasks if necessary
172
180
  end
@@ -185,8 +193,13 @@ class LbhrrCLI < Thor
185
193
  config = load_configuration
186
194
  host = config["host"]
187
195
  user = config["user"]
196
+
188
197
  puts "Destroying app: #{container_name}"
189
198
  `ssh #{user}@#{host} 'harbr destroy #{container_name}'`
199
+ unless manifest?
200
+ puts "no manifest found!"
201
+ return
202
+ end
190
203
 
191
204
  current_dir = Dir.pwd
192
205
  parent_dir = File.dirname(current_dir)
@@ -228,15 +241,17 @@ class LbhrrCLI < Thor
228
241
  basename = File.basename(Dir.pwd)
229
242
  base_directory = "/var/harbr/containers/#{basename}"
230
243
  versions_directory = "#{base_directory}/versions"
244
+ data_directory = "/var/dddr/#{basename}/"
231
245
  destination_path = "#{versions_directory}/#{version}"
232
-
233
- # Check and create the versions directory on the server
234
- `ssh #{user}@#{host} 'mkdir -p #{versions_directory}'`
235
-
236
246
  # Prepare the rsync exclude option using .gitignore
237
247
  gitignore_path = File.join(Dir.pwd, ".gitignore")
238
248
  exclude_option = File.exist?(gitignore_path) ? "--exclude='.git' --exclude-from='#{gitignore_path}'" : ""
239
249
 
250
+
251
+ # Check and create the versions directory on the server
252
+ `ssh #{user}@#{host} 'mkdir -p #{versions_directory}'`
253
+ `ssh #{user}@#{host} 'mkdir -p #{data_directory}'`
254
+
240
255
  # Rsync files to the new version directory, excluding files as per .gitignore
241
256
  rsync_command = "rsync -avz #{exclude_option} ./ #{user}@#{host}:#{destination_path}"
242
257
 
@@ -251,12 +266,29 @@ class LbhrrCLI < Thor
251
266
  end
252
267
 
253
268
  desc "logs", "Show logs for a container"
254
- def logs
255
- container_name = File.basename(Dir.pwd)
269
+ method_option :live, type: :boolean, aliases: "-l", desc: "Process in live mode"
270
+ method_option :next, type: :boolean, default: true, aliases: "-n", desc: "Process in next mode"
271
+ def logs(name=nil)
256
272
  config = load_configuration
257
273
  host = config["host"]
258
274
  user = config["user"]
259
- exec "ssh #{user}@#{host} 'harbr peek #{container_name}'"
275
+
276
+ if name.nil?
277
+ unless manifest?
278
+ puts "no manifest found!"
279
+ return
280
+ end
281
+
282
+ container_name = File.basename(Dir.pwd)
283
+ else
284
+ container_name = name
285
+ end
286
+
287
+ if options[:live]
288
+ exec "ssh #{user}@#{host} 'harbr peek #{container_name} --live'"
289
+ else
290
+ exec "ssh #{user}@#{host} 'harbr peek #{container_name} --next'"
291
+ end
260
292
  end
261
293
 
262
294
 
@@ -271,22 +303,34 @@ class LbhrrCLI < Thor
271
303
 
272
304
 
273
305
  desc "hoist", "Deploy an application using the configuration from config/manifest.yml to production"
274
- def hoist
275
- config = load_configuration
276
- host = config["host"]
277
- user = config["user"]
278
- name = config["name"]
306
+ def hoist(name=nil)
307
+ if name.nil?
308
+ unless manifest?
309
+ puts "no manifest found!"
310
+ return
311
+ end
279
312
 
313
+ config = load_configuration
314
+ host = config["host"]
315
+ user = config["user"]
316
+ name = config["name"]
317
+ end
280
318
  puts `ssh #{user}@#{host} 'harbr deploy #{name}'`
281
319
  end
282
320
 
283
321
  desc "rollback", "rollback an application using the configuration from config/manifest.yml"
284
- def rollback
285
- config = load_configuration
286
- host = config["host"]
287
- user = config["user"]
288
- name = config["name"]
322
+ def rollback(name=nil)
323
+ if name.nil?
324
+ unless manifest?
325
+ puts "no manifest found!"
326
+ return
327
+ end
289
328
 
329
+ config = load_configuration
330
+ host = config["host"]
331
+ user = config["user"]
332
+ name = config["name"]
333
+ end
290
334
  puts `ssh #{user}@#{host} 'harbr rollback #{name}'`
291
335
  end
292
336
 
data/lib/lbhrr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Lbhrr
4
- VERSION = "1.0.14"
4
+ VERSION = "1.0.18"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbhrr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.14
4
+ version: 1.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delaney Kuldvee Burke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-16 00:00:00.000000000 Z
11
+ date: 2023-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh