Skip to content

Commit 30d6b9e

Browse files
authored
Release 3.4.2
2 parents b36750c + 0cab618 commit 30d6b9e

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.4.1
1+
3.4.2

resources/lib/service.rb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,15 @@ def execute(node=nil, service)
609609
utils = Utils.instance
610610
saved = false
611611
protected_services = ['s3', 'redis', 'postgresql'] # Mandatory services that cannot be disabled if only one node is running
612-
612+
613+
if service == 'postgresql' && !Dir.exist?('/var/lib/pgsql/data')
614+
puts 'PostgreSQL already disabled.'
615+
return
616+
elsif service == 'postgresql' && utils.postgres_master?
617+
puts 'ERROR: Cannot disable PostgreSQL on this node because it is the master.'
618+
return
619+
end
620+
613621
begin
614622
nodes = utils.check_nodes(node || Socket.gethostname.split(".").first)
615623
if nodes.count == 0
@@ -790,6 +798,14 @@ def execute(node, *services)
790798
end
791799
end
792800

801+
if services.include?('postgresql') && !Dir.exist?('/var/lib/pgsql/data')
802+
puts 'PostgreSQL already disabled.'
803+
return
804+
elsif services.include?('postgresql') && utils.postgres_master?
805+
puts 'ERROR: Cannot stop PostgreSQL on this node because it is the master.'
806+
return
807+
end
808+
793809
nodes.each do |n|
794810
node = utils.get_node(n)
795811

resources/lib/utils.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,18 @@ def get_logstash_plugins
7878
logstash_api_query('_node/plugins')
7979
end
8080

81+
def postgres_master?
82+
pg_data = '/var/lib/pgsql/data'
83+
standby_file = File.join(pg_data, 'standby.signal')
84+
pg_conf = File.join(pg_data, 'postgresql.conf')
85+
86+
return false if File.exist?(standby_file) ||
87+
File.read(pg_conf) =~ /primary_conninfo\s*=/ ||
88+
File.read(pg_conf) =~ /promote_trigger_file\s*=/
89+
90+
true
91+
end
92+
8193
# curl -XGET 'localhost:9600/_node/stats/pipelines/vault-pipeline'
8294

8395
def logstash_api_query(action)

0 commit comments

Comments
 (0)