switchman 3.5.1 → 3.5.2
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a91e85cce6bc5ae253213341573bb4937692ce0763bb4359ffa5ee4b12d8a2e
|
4
|
+
data.tar.gz: deae9f167202394f6a8d02910a911f4d64a2d944ed9406f0263861b8f609ca82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85626eedd9e74291cbad627523936750dc5a3551bc9cd77e6dd5c49790edeb2e392d974f394bc1f94205b82447be2d4b71c8a108ab63f77947021b6402a64327
|
7
|
+
data.tar.gz: e288052614bb7e4a872a5aba886829b0b86f1f9105914cfc947badd6ae3323da7e2cbac835521321a71200cd612d2e945ce474546cb87b71205a240e910d1af6
|
@@ -27,12 +27,17 @@ module Switchman
|
|
27
27
|
return configs if configs.is_a?(Array)
|
28
28
|
|
29
29
|
db_configs = configs.flat_map do |env_name, config|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
if config.is_a?(Hash)
|
31
|
+
# It would be nice to do the auto-fallback that we want here, but we haven't
|
32
|
+
# actually done that for years (or maybe ever) and it will be a big lift to get working
|
33
|
+
roles = config.keys.select do |k|
|
34
|
+
config[k].is_a?(Hash) || (config[k].is_a?(Array) && config[k].all?(Hash))
|
35
|
+
end
|
36
|
+
base_config = config.except(*roles)
|
37
|
+
else
|
38
|
+
base_config = config
|
39
|
+
roles = []
|
34
40
|
end
|
35
|
-
base_config = config.except(*roles)
|
36
41
|
|
37
42
|
name = "#{env_name}/primary"
|
38
43
|
name = "primary" if env_name == default_env
|
@@ -81,6 +81,8 @@ module Switchman
|
|
81
81
|
# Do this after so that all database servers for all roles are established and we won't prematurely
|
82
82
|
# configure a connection for the wrong role
|
83
83
|
@all_roles = roles.uniq
|
84
|
+
return @database_servers if @database_servers.empty?
|
85
|
+
|
84
86
|
Shard.send(:configure_connects_to)
|
85
87
|
end
|
86
88
|
@database_servers
|
data/lib/switchman/shard.rb
CHANGED
@@ -168,7 +168,7 @@ module Switchman
|
|
168
168
|
# silly like dealloc'ing prepared statements)
|
169
169
|
::ActiveRecord::Base.clear_all_connections!
|
170
170
|
|
171
|
-
parent_process_name =
|
171
|
+
parent_process_name = sanitized_process_title
|
172
172
|
ret = ::Parallel.map(scopes, in_processes: (scopes.length > 1) ? parallel : 0) do |server, subscope|
|
173
173
|
name = server.id
|
174
174
|
last_description = name
|
@@ -444,6 +444,39 @@ module Switchman
|
|
444
444
|
shard = nil unless shard.database_server
|
445
445
|
shard
|
446
446
|
end
|
447
|
+
|
448
|
+
# Determines the name of the current process, including arguments, but stripping
|
449
|
+
# any shebang from the invoked script, and any additional path info from the
|
450
|
+
# executable.
|
451
|
+
#
|
452
|
+
# @return [String]
|
453
|
+
def sanitized_process_title
|
454
|
+
# get the effective process name from `ps`; this will include any changes
|
455
|
+
# from Process.setproctitle _or_ assigning to $0.
|
456
|
+
parent_process_name = `ps -ocommand= -p#{Process.pid}`.strip
|
457
|
+
# Effective process titles may be shorter than the actual
|
458
|
+
# command; truncate our ARGV[0] so that they are comparable
|
459
|
+
# for the next step
|
460
|
+
argv0 = if parent_process_name.length < Process.argv0.length
|
461
|
+
Process.argv0[0..parent_process_name.length]
|
462
|
+
else
|
463
|
+
Process.argv0
|
464
|
+
end
|
465
|
+
|
466
|
+
# when running via a shebang, the `ps` output will include the shebang
|
467
|
+
# (i.e. it will be "ruby bin/rails c"); attempt to strip it off.
|
468
|
+
# Note that argv0 in this case will _only_ be `bin/rails` (no shebang,
|
469
|
+
# no arguments). We want to preserve the arguments we got from `ps`
|
470
|
+
if (index = parent_process_name.index(argv0))
|
471
|
+
parent_process_name.slice!(0...index)
|
472
|
+
end
|
473
|
+
|
474
|
+
# remove directories from the main executable to make more room
|
475
|
+
# for additional info
|
476
|
+
argv = parent_process_name.shellsplit
|
477
|
+
argv[0] = File.basename(argv[0])
|
478
|
+
argv.shelljoin
|
479
|
+
end
|
447
480
|
end
|
448
481
|
|
449
482
|
def name
|
data/lib/switchman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switchman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cody Cutrer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2023-05-
|
13
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|