Skip to content

Commit 70a576d

Browse files
committed
ezbake: Introduce service-port variable
This adds a bit of a startup delay to ensure that systemd not just starts the process and thinks the service is already up and running. Previously this was handled by the wrapper script and Type=forking. This commit fixes a regression from OpenVoxProject@b2de7c7 This also requires changes to the projects to provide the actual port. * OpenVoxProject/openvox-server#80 * OpenVoxProject/openvoxdb#69 This is just a workaround and not a perfect solution. For systemd-based systemd we should implement sd_notify and switch to Type=notify-reload. https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#Type=
1 parent 86b1177 commit 70a576d

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

resources/puppetlabs/lein-ezbake/staging-templates/ezbake.rb.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module EZBake
22
Config = {
3+
:service_port => {{{service-port}}},
34
:project => {{{project}}},
45
:version => {{{packaging-version}}},
56
:release => {{{packaging-release}}},

resources/puppetlabs/lein-ezbake/template/global/ext/redhat/ezbake.service.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ ExecStart=<%= EZBake::Config[:java_bin] %> $JAVA_ARGS -Dlogappender=F1 \
6363

6464
KillMode=process
6565

66+
<% if EZBake::Config[:service_port] -%>
67+
# Wait until the service is started and opened the correct TCP port
68+
ExecStartPost=timeout 30s sh -c 'while ! ss -H -t -l -n sport = :<%= EZBake::Config[:service_port] %> | grep -q "^LISTEN.*:<%= EZBake::Config[:service_port] %>"; do sleep 1s; done'
69+
<% end -%>
6670
<% EZBake::Config[:redhat][:post_start_action].each do |action| -%>
6771
ExecStartPost=-<%= action %>
6872
<% end -%>

src/puppetlabs/ezbake/core.clj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
(def LocalProjectVars
7272
{(schema/optional-key :user) schema/Str
7373
(schema/optional-key :numeric-uid-gid) schema/Int
74+
(schema/optional-key :service-port) schema/Int
7475
(schema/optional-key :group) schema/Str
7576
(schema/optional-key :puppet-platform-version) schema/Int
7677
(schema/optional-key :bootstrap-source) BootstrapSource
@@ -608,6 +609,7 @@ Additional uberjar dependencies:
608609
:real-name (-> (:name lein-project) get-real-name as-ruby-literal)
609610
:user (local->ruby :user (:name lein-project))
610611
:numeric-uid-gid (local->ruby :numeric-uid-gid nil)
612+
:service-port (local->ruby :service-port nil)
611613
:group (local->ruby :group (:name lein-project))
612614
:uberjar-name (as-ruby-literal (:uberjar-name lein-project))
613615
:config-files (as-ruby-literal (map remove-erb-extension config-files))

test/unit/puppetlabs/ezbake/core_test.clj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
(deftest trivial-make-template-map-behavior
3333
(testing "keyword bootstrap-source value with hyphens is ok"
3434
(let [expected {:numeric-uid-gid "nil"
35+
:service-port "nil"
3536
:debian-prerm "[]"
3637
:config-files "[]"
3738
:main-namespace "'puppetlabs.trapperkeeper.main'"

0 commit comments

Comments
 (0)