lbhrr 1.0.14 → 1.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/exe/lbhrr +71 -47
  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: 2c16598588fb0dd4b1594716029304841660319bca7bbe4f07fe82c8614d3efc
4
+ data.tar.gz: c5bd2ed54c4bc0af9add6155fe51f67e460005b2df5dfa7f91a394e940d022cb
5
5
  SHA512:
6
- metadata.gz: 95fe5d60e5b94f0e7a08eb32543a555d24595d87f56e8ace942bb96701e6657cda2796b4ec868a50430b5b645893e9277854bff143d34074d85297c4169deb40
7
- data.tar.gz: f202266c171819ae6ef96a2b12483615eb4c0a06a988f1b34770f60deacc8cb066eb629c41af0bdf232ecfb9e22c1a7336688c0d65be8dccbfab3a22593c3731
6
+ metadata.gz: 05f4321bdfcc221108e26b9500dfb564474e11ffab4f6e1d2b0a1ea162a3be229121960d641faf3ed624022985bd5fbfa085c063139536236fb8f1e25b832a2b
7
+ data.tar.gz: 7f8e65ee5180f1f8aa14660609997fdcd73e27c1f53e84f8191207e692c3f5097612dfabb1eafe2046f7c0b16f49431ed8b17f99efc63515a4e14e7bf3a81ef9
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
@@ -180,31 +188,16 @@ class LbhrrCLI < Thor
180
188
  end
181
189
 
182
190
  desc "drop", "Destroy an app and remove all traces"
183
- def drop
184
- container_name = File.basename(Dir.pwd)
185
- config = load_configuration
186
- host = config["host"]
187
- user = config["user"]
188
- puts "Destroying app: #{container_name}"
189
- `ssh #{user}@#{host} 'harbr destroy #{container_name}'`
190
-
191
- current_dir = Dir.pwd
192
- parent_dir = File.dirname(current_dir)
193
-
194
- # Requesting confirmation
195
- if yes? "Are you sure you want to delete the directory: #{current_dir}? [y/N]"
196
- # Proceeding with deletion
197
- puts "Changing directory to the parent directory..."
198
- Dir.chdir(parent_dir)
199
-
200
- puts "Deleting the directory: #{current_dir}"
201
- FileUtils.rm_rf(current_dir)
202
-
203
- Dir.chdir(parent_dir)
204
-
205
- puts "#{current_dir} has been deleted."
206
-
191
+ def drop(name=nil)
192
+ if name.nil?
193
+ container_name = File.basename(Dir.pwd)
194
+ config = load_configuration
195
+ host = config["host"]
196
+ user = config["user"]
197
+ name = config["name"]
207
198
  end
199
+ puts "Destroying app: #{name}"
200
+ `ssh #{user}@#{host} 'harbr destroy #{name}'`
208
201
 
209
202
  puts "App #{container_name} has been successfully destroyed."
210
203
  end
@@ -228,15 +221,17 @@ class LbhrrCLI < Thor
228
221
  basename = File.basename(Dir.pwd)
229
222
  base_directory = "/var/harbr/containers/#{basename}"
230
223
  versions_directory = "#{base_directory}/versions"
224
+ data_directory = "/var/dddr/#{basename}/"
231
225
  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
226
  # Prepare the rsync exclude option using .gitignore
237
227
  gitignore_path = File.join(Dir.pwd, ".gitignore")
238
228
  exclude_option = File.exist?(gitignore_path) ? "--exclude='.git' --exclude-from='#{gitignore_path}'" : ""
239
229
 
230
+
231
+ # Check and create the versions directory on the server
232
+ `ssh #{user}@#{host} 'mkdir -p #{versions_directory}'`
233
+ `ssh #{user}@#{host} 'mkdir -p #{data_directory}'`
234
+
240
235
  # Rsync files to the new version directory, excluding files as per .gitignore
241
236
  rsync_command = "rsync -avz #{exclude_option} ./ #{user}@#{host}:#{destination_path}"
242
237
 
@@ -251,12 +246,29 @@ class LbhrrCLI < Thor
251
246
  end
252
247
 
253
248
  desc "logs", "Show logs for a container"
254
- def logs
255
- container_name = File.basename(Dir.pwd)
249
+ method_option :live, type: :boolean, aliases: "-l", desc: "Process in live mode"
250
+ method_option :next, type: :boolean, default: true, aliases: "-n", desc: "Process in next mode"
251
+ def logs(name=nil)
256
252
  config = load_configuration
257
253
  host = config["host"]
258
254
  user = config["user"]
259
- exec "ssh #{user}@#{host} 'harbr peek #{container_name}'"
255
+
256
+ if name.nil?
257
+ unless manifest?
258
+ puts "no manifest found!"
259
+ return
260
+ end
261
+
262
+ container_name = File.basename(Dir.pwd)
263
+ else
264
+ container_name = name
265
+ end
266
+
267
+ if options[:live]
268
+ exec "ssh #{user}@#{host} 'harbr peek #{container_name} --live'"
269
+ else
270
+ exec "ssh #{user}@#{host} 'harbr peek #{container_name} --next'"
271
+ end
260
272
  end
261
273
 
262
274
 
@@ -271,22 +283,34 @@ class LbhrrCLI < Thor
271
283
 
272
284
 
273
285
  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"]
286
+ def hoist(name=nil)
287
+ if name.nil?
288
+ unless manifest?
289
+ puts "no manifest found!"
290
+ return
291
+ end
279
292
 
293
+ config = load_configuration
294
+ host = config["host"]
295
+ user = config["user"]
296
+ name = config["name"]
297
+ end
280
298
  puts `ssh #{user}@#{host} 'harbr deploy #{name}'`
281
299
  end
282
300
 
283
301
  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"]
302
+ def rollback(name=nil)
303
+ if name.nil?
304
+ unless manifest?
305
+ puts "no manifest found!"
306
+ return
307
+ end
289
308
 
309
+ config = load_configuration
310
+ host = config["host"]
311
+ user = config["user"]
312
+ name = config["name"]
313
+ end
290
314
  puts `ssh #{user}@#{host} 'harbr rollback #{name}'`
291
315
  end
292
316
 
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.19"
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.19
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