lbhrr 1.0.23 → 1.0.26
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.
- checksums.yaml +4 -4
- data/exe/lbhrr +106 -57
- data/lib/lbhrr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cf67c16657d7441eb1afe1cbe45d92b091582d0909860277bba699fba9409c7
|
4
|
+
data.tar.gz: d3c9bed0e42a7081a639ca0e6341f8fa783e4f848a125125a35d7ed2971d6053
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd05fb0380b15ba715342597d558c7477c85719da51e5f2f8b17e77b89bb900613417465d2230209b6a3c8a80702eba2c5d51e6da76d30d9427e5f3e93f9a46d
|
7
|
+
data.tar.gz: c20241b685a9f0a03dd859a1781a2e22053c9a529a3da52013e514e9bf0a6e0ba88eb9a792f15a6ead66827fc860cce56699a0ef53c060e9d62d0b41fb4aa387
|
data/exe/lbhrr
CHANGED
@@ -5,7 +5,7 @@ class LbhrrCLI < Thor
|
|
5
5
|
no_commands do
|
6
6
|
|
7
7
|
def manifest?
|
8
|
-
File.join(Dir.pwd, "config","manifest.yml")
|
8
|
+
File.exist? File.join(Dir.pwd, "config","manifest.yml")
|
9
9
|
end
|
10
10
|
|
11
11
|
def package
|
@@ -32,8 +32,7 @@ class LbhrrCLI < Thor
|
|
32
32
|
system("git add .") or raise "Failed to add changes to Git"
|
33
33
|
system("git commit -m 'packaged #{version}'") or raise "Failed to commit changes to Git"
|
34
34
|
puts "Packaging completed successfully."
|
35
|
-
|
36
|
-
puts "Packaging error: #{e.message}"
|
35
|
+
|
37
36
|
end
|
38
37
|
|
39
38
|
def amend_last_commit(new_message)
|
@@ -101,24 +100,64 @@ class LbhrrCLI < Thor
|
|
101
100
|
YAML.dump(example_global_config)
|
102
101
|
end
|
103
102
|
|
104
|
-
def create_run_file
|
105
|
-
|
106
|
-
|
107
|
-
|
103
|
+
def create_run_file(type)
|
104
|
+
|
105
|
+
service_content = <<-RUBY
|
106
|
+
#!/usr/bin/env ruby
|
107
|
+
require 'bundler/inline'
|
108
|
+
|
109
|
+
gemfile do
|
110
|
+
source 'https://rubygems.org'
|
111
|
+
#gem 'kafkr', require: true
|
112
|
+
end
|
113
|
+
|
114
|
+
puts 'Gems installed and loaded!'
|
115
|
+
|
116
|
+
loop do
|
117
|
+
puts 'ok!'
|
118
|
+
sleep 1
|
119
|
+
end
|
120
|
+
|
121
|
+
RUBY
|
122
|
+
|
123
|
+
if type == "web"
|
124
|
+
run_file_path = File.join(Dir.pwd, "exe", "run")
|
125
|
+
web_run_file_content = "#!/bin/sh\n HARBR_ENV=$2 bundle exec puma -p $1"
|
126
|
+
exe_directory = File.join(Dir.pwd, "exe")
|
127
|
+
|
128
|
+
Dir.mkdir(exe_directory) unless Dir.exist?(exe_directory)
|
129
|
+
File.write(run_file_path, web_run_file_content)
|
130
|
+
File.chmod(0o755, run_file_path) # Set executable permission
|
131
|
+
puts "Created ./exe/run file."
|
132
|
+
end
|
133
|
+
|
134
|
+
if type == "service"
|
135
|
+
run_file_path = File.join(Dir.pwd, "exe", "run")
|
136
|
+
service_run_file_content = "#!/bin/sh\n HARBR_ENV=$2 ruby service"
|
137
|
+
exe_directory = File.join(Dir.pwd, "exe")
|
138
|
+
|
139
|
+
Dir.mkdir(exe_directory) unless Dir.exist?(exe_directory)
|
140
|
+
File.write(run_file_path, service_run_file_content)
|
141
|
+
File.chmod(0o755, run_file_path) # Set executable permission
|
142
|
+
puts "Created ./exe/run file."
|
143
|
+
|
144
|
+
File.write("service", service_content)
|
145
|
+
File.chmod(0o755, "service") # Set executable permission
|
146
|
+
puts "Created ./service file."
|
147
|
+
|
148
|
+
end
|
108
149
|
|
109
|
-
|
110
|
-
File.write(run_file_path, run_file_content)
|
111
|
-
File.chmod(0o755, run_file_path) # Set executable permission
|
150
|
+
|
112
151
|
|
113
|
-
puts "Created ./exe/run file."
|
114
152
|
rescue => e
|
115
153
|
puts "Error creating ./exe/run file: #{e.message}"
|
116
154
|
end
|
117
155
|
|
118
|
-
def create_example_local_config
|
156
|
+
def create_example_local_config(type)
|
119
157
|
example_local_config = {
|
120
158
|
"name" => File.basename(Dir.pwd),
|
121
159
|
"version" => "0",
|
160
|
+
"type" => type,
|
122
161
|
"port" => "#{File.basename(Dir.pwd)}.app",
|
123
162
|
"host" => "#{File.basename(Dir.pwd)}.harbr.zero2one.ee"
|
124
163
|
}
|
@@ -163,17 +202,19 @@ class LbhrrCLI < Thor
|
|
163
202
|
end
|
164
203
|
|
165
204
|
desc "init", "Initialize project with .gitignore"
|
205
|
+
method_option :type, type: :string, enum: ['web', 'service'], default: 'web', desc: "Specify the type of process"
|
166
206
|
def init
|
167
207
|
local_config_path = File.join(Dir.pwd, "config", "manifest.yml")
|
168
208
|
|
169
209
|
unless File.exist?(local_config_path)
|
170
210
|
FileUtils.mkdir_p(File.dirname(local_config_path)) unless Dir.exist?(File.dirname(local_config_path))
|
171
|
-
File.write(local_config_path, create_example_local_config)
|
211
|
+
File.write(local_config_path, create_example_local_config(options[:type]))
|
172
212
|
end
|
173
213
|
# Load and merge configurations
|
174
214
|
local_config = YAML.load_file(local_config_path) || {}
|
175
215
|
create_gitignore
|
176
|
-
create_run_file
|
216
|
+
create_run_file(options[:type])
|
217
|
+
|
177
218
|
|
178
219
|
|
179
220
|
# Include other initialization tasks if necessary
|
@@ -194,7 +235,13 @@ class LbhrrCLI < Thor
|
|
194
235
|
user = config["user"]
|
195
236
|
|
196
237
|
if name.nil?
|
197
|
-
|
238
|
+
|
239
|
+
unless manifest?
|
240
|
+
puts "no manifest found!"
|
241
|
+
return
|
242
|
+
end
|
243
|
+
|
244
|
+
name = config["name"]
|
198
245
|
end
|
199
246
|
|
200
247
|
puts "Destroying app: #{name}"
|
@@ -205,50 +252,51 @@ class LbhrrCLI < Thor
|
|
205
252
|
|
206
253
|
desc "raise", "Deploy an application using the configuration from config/manifest.yml to staging"
|
207
254
|
def raise
|
208
|
-
|
255
|
+
if manifest?
|
256
|
+
|
257
|
+
package
|
258
|
+
|
259
|
+
|
260
|
+
config = load_configuration
|
261
|
+
host = config["host"]
|
262
|
+
user = config["user"]
|
263
|
+
raise "Host configuration missing" unless host
|
264
|
+
|
265
|
+
local_manifest_path = File.join(Dir.pwd, "config", "manifest.yml")
|
266
|
+
raise "Local manifest file not found at #{local_manifest_path}" unless File.exist?(local_manifest_path)
|
267
|
+
|
268
|
+
local_config = YAML.load_file(local_manifest_path) || {}
|
269
|
+
version = local_config["version"].to_i
|
270
|
+
raise "Version not specified in manifest.yml" unless version
|
271
|
+
|
272
|
+
basename = File.basename(Dir.pwd)
|
273
|
+
base_directory = "/var/harbr/containers/#{basename}"
|
274
|
+
versions_directory = "#{base_directory}/versions"
|
275
|
+
data_directory = "/var/dddr/#{basename}/"
|
276
|
+
destination_path = "#{versions_directory}/#{version}"
|
277
|
+
# Prepare the rsync exclude option using .gitignore
|
278
|
+
gitignore_path = File.join(Dir.pwd, ".gitignore")
|
279
|
+
exclude_option = File.exist?(gitignore_path) ? "--exclude='.git' --exclude-from='#{gitignore_path}'" : ""
|
280
|
+
|
281
|
+
|
282
|
+
# Check and create the versions directory on the server
|
283
|
+
`ssh #{user}@#{host} 'mkdir -p #{versions_directory}'`
|
284
|
+
`ssh #{user}@#{host} 'mkdir -p #{data_directory}'`
|
285
|
+
|
286
|
+
# Rsync files to the new version directory, excluding files as per .gitignore
|
287
|
+
rsync_command = "rsync -avz #{exclude_option} ./ #{user}@#{host}:#{destination_path}"
|
288
|
+
|
289
|
+
if `#{rsync_command}`
|
290
|
+
puts "Successfully deployed application version #{version} to #{host}"
|
291
|
+
deployed(local_manifest_path, version)
|
292
|
+
else
|
293
|
+
puts "Failed to deploy application version #{version} to #{host}"
|
294
|
+
end
|
295
|
+
|
296
|
+
else
|
209
297
|
puts "no manifest found!"
|
210
|
-
return
|
211
298
|
end
|
212
299
|
|
213
|
-
package
|
214
|
-
|
215
|
-
config = load_configuration
|
216
|
-
host = config["host"]
|
217
|
-
user = config["user"]
|
218
|
-
raise "Host configuration missing" unless host
|
219
|
-
|
220
|
-
local_manifest_path = File.join(Dir.pwd, "config", "manifest.yml")
|
221
|
-
raise "Local manifest file not found at #{local_manifest_path}" unless File.exist?(local_manifest_path)
|
222
|
-
|
223
|
-
local_config = YAML.load_file(local_manifest_path) || {}
|
224
|
-
version = local_config["version"].to_i
|
225
|
-
raise "Version not specified in manifest.yml" unless version
|
226
|
-
|
227
|
-
basename = File.basename(Dir.pwd)
|
228
|
-
base_directory = "/var/harbr/containers/#{basename}"
|
229
|
-
versions_directory = "#{base_directory}/versions"
|
230
|
-
data_directory = "/var/dddr/#{basename}/"
|
231
|
-
destination_path = "#{versions_directory}/#{version}"
|
232
|
-
# Prepare the rsync exclude option using .gitignore
|
233
|
-
gitignore_path = File.join(Dir.pwd, ".gitignore")
|
234
|
-
exclude_option = File.exist?(gitignore_path) ? "--exclude='.git' --exclude-from='#{gitignore_path}'" : ""
|
235
|
-
|
236
|
-
|
237
|
-
# Check and create the versions directory on the server
|
238
|
-
`ssh #{user}@#{host} 'mkdir -p #{versions_directory}'`
|
239
|
-
`ssh #{user}@#{host} 'mkdir -p #{data_directory}'`
|
240
|
-
|
241
|
-
# Rsync files to the new version directory, excluding files as per .gitignore
|
242
|
-
rsync_command = "rsync -avz #{exclude_option} ./ #{user}@#{host}:#{destination_path}"
|
243
|
-
|
244
|
-
if `#{rsync_command}`
|
245
|
-
puts "Successfully deployed application version #{version} to #{host}"
|
246
|
-
deployed(local_manifest_path, version)
|
247
|
-
else
|
248
|
-
puts "Failed to deploy application version #{version} to #{host}"
|
249
|
-
end
|
250
|
-
rescue => e
|
251
|
-
puts "Deployment error: #{e.message}"
|
252
300
|
end
|
253
301
|
|
254
302
|
desc "logs", "Show logs for a container"
|
@@ -265,7 +313,8 @@ class LbhrrCLI < Thor
|
|
265
313
|
return
|
266
314
|
end
|
267
315
|
|
268
|
-
container_name =
|
316
|
+
container_name = config["name"]
|
317
|
+
|
269
318
|
else
|
270
319
|
container_name = name
|
271
320
|
end
|
data/lib/lbhrr/version.rb
CHANGED