smart_proxy_dynflow_core 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e605170d98b043dbebe0199fa07878a479c49517398b76b9ea8763b3f11a944
4
- data.tar.gz: 3ca809db6838f8922b523c05b9009f7c06f6f3b7b225f708c0250dab92ee42e5
3
+ metadata.gz: 84ea792e8e6d9f6ddcd145428485d5faadf92da27acd184fa42956fa4873e7fd
4
+ data.tar.gz: 07adc8b3c623462086d0797455afaf822e27212bcdcda345a950df7e49296814
5
5
  SHA512:
6
- metadata.gz: 83e7a7cefc7149bbdd9ea1fe75e10abcf3b3264aff1831e64aa87ac9e136404e35c5caf18d376e40be6d7ea845815f30aaa7a3a654d25236d437d7db84472f95
7
- data.tar.gz: f748d215cca4ddf825b5f692568f162afdaf16aa394efb776df551365eaf1a09a925f9698a30f16e68c249865976a3aa8115ce5149e845403d1a7598f5de6380
6
+ metadata.gz: 989f9619b041039a3897de03cac1edc5ce1415a19792b3a5b2e907b174b97472b3a56f19cd5cab9977c26e5d5c83c38636afe8c49186dbd2bfce1c7e3dbfcc84
7
+ data.tar.gz: 7caa3ee4ddce3560970bd8f7a7b8e2b99dd96f1fae456e78475673ec98478e0c608e5feb29442b7046e4eed07e61f0d9a009dade6646e534f6ef6f033192f572
@@ -4,10 +4,9 @@ Documentation=https://github.com/theforeman/smart_proxy_dynflow
4
4
  After=network.target remote-fs.target nss-lookup.target
5
5
 
6
6
  [Service]
7
- Type=forking
7
+ Type=notify
8
8
  User=foreman-proxy
9
- PIDFile=/var/run/foreman-proxy/smart_proxy_dynflow_core.pid
10
- ExecStart=/usr/bin/smart_proxy_dynflow_core -d -p /var/run/foreman-proxy/smart_proxy_dynflow_core.pid
9
+ ExecStart=/usr/bin/smart_proxy_dynflow_core --no-daemonize
11
10
  EnvironmentFile=-/etc/sysconfig/smart_proxy_dynflow_core
12
11
 
13
12
  [Install]
@@ -1,6 +1,7 @@
1
1
  require 'webrick/https'
2
2
  require 'smart_proxy_dynflow_core/bundler_helper'
3
3
  require 'smart_proxy_dynflow_core/settings'
4
+ require 'smart_proxy_dynflow_core/sd_notify'
4
5
 
5
6
  module SmartProxyDynflowCore
6
7
  class Launcher
@@ -18,6 +19,7 @@ module SmartProxyDynflowCore
18
19
  install_usr1_trap
19
20
  Rack::Server.new(rack_settings).start do |_server|
20
21
  SmartProxyDynflowCore::Core.ensure_initialized
22
+ SmartProxyDynflowCore::SdNotify.new.tap { |sd| sd.ready if sd.active? }
21
23
  end
22
24
  end
23
25
 
@@ -82,7 +84,7 @@ module SmartProxyDynflowCore
82
84
  :AccessLog => [[Log.instance, WEBrick::AccessLog::COMMON_LOG_FORMAT]],
83
85
  :Logger => Log.instance,
84
86
  :daemonize => Settings.instance.daemonize,
85
- :pid => Settings.instance.pid_file,
87
+ :pid => Settings.instance.daemonize && Settings.instance.pid_file,
86
88
  :server => :webrick
87
89
  }
88
90
  end
@@ -0,0 +1,33 @@
1
+ # Shamelessly taken from theforeman/smart-proxy @ 99e9e5b
2
+ # kudos to domcleal
3
+
4
+ require 'socket'
5
+
6
+ # Implementation of libsystemd's sd_notify API, sends current state via socket
7
+ module SmartProxyDynflowCore
8
+ class SdNotify
9
+ def active?
10
+ !ENV['NOTIFY_SOCKET'].nil?
11
+ end
12
+
13
+ def notify(message)
14
+ create_socket.tap do |socket|
15
+ socket.sendmsg(message.chomp + "\n") # ensure trailing \n
16
+ socket.close
17
+ end
18
+ end
19
+
20
+ def ready(state = 1)
21
+ notify("READY=#{state}")
22
+ end
23
+
24
+ private
25
+
26
+ def create_socket
27
+ raise 'Missing NOTIFY_SOCKET environment variable, is this process running under systemd?' unless active?
28
+ Socket.new(Socket::AF_UNIX, Socket::SOCK_DGRAM, 0).tap do |socket|
29
+ socket.connect(Socket.pack_sockaddr_un(ENV['NOTIFY_SOCKET']))
30
+ end
31
+ end
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module SmartProxyDynflowCore
2
- VERSION = '0.2.5'.freeze
2
+ VERSION = '0.2.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_dynflow_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-06 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -214,6 +214,7 @@ files:
214
214
  - lib/smart_proxy_dynflow_core/helpers.rb
215
215
  - lib/smart_proxy_dynflow_core/launcher.rb
216
216
  - lib/smart_proxy_dynflow_core/log.rb
217
+ - lib/smart_proxy_dynflow_core/sd_notify.rb
217
218
  - lib/smart_proxy_dynflow_core/settings.rb
218
219
  - lib/smart_proxy_dynflow_core/task_launcher_registry.rb
219
220
  - lib/smart_proxy_dynflow_core/testing.rb