Skip to content

Commit

Permalink
Restart Beat after install on deb package (#36201)
Browse files Browse the repository at this point in the history
This commit restarts the Beat after the deb package is installed. When
upgrading a Beat via deb packages this is required for the new version
to start running.

The post install script checks whether the Beat is running, if so, then
it restarts the service.
  • Loading branch information
belimawr authored Aug 4, 2023
1 parent a2eaff7 commit c0f53cf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Eliminate cloning of event in deepUpdate {pull}35945[35945]
- Fix ndjson parser to store JSON fields correctly under `target` {issue}29395[29395]
- Support build of projects outside of beats directory {pull}36126[36126]
- After upgrade the deb package now restarts the Beat service {issue}34089[34089] {pull}36201[36201]



Expand Down
4 changes: 0 additions & 4 deletions dev-tools/packaging/files/linux/systemd-daemon-reload.sh

This file was deleted.

4 changes: 2 additions & 2 deletions dev-tools/packaging/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ shared:
# Deb/RPM spec for community beats.
- &deb_rpm_spec
<<: *common
post_install_script: '{{ elastic_beats_dir }}/dev-tools/packaging/files/linux/systemd-daemon-reload.sh'
post_install_script: '{{ elastic_beats_dir }}/dev-tools/packaging/templates/deb/postinstall.sh.tmpl'
files:
/usr/share/{{.BeatName}}/bin/{{.BeatName}}{{.BinaryExt}}:
source: build/golang-crossbuild/{{.BeatName}}-{{.GOOS}}-{{.Platform.Arch}}{{.BinaryExt}}
Expand Down Expand Up @@ -618,4 +618,4 @@ specs:
'{{.BeatName}}{{.BinaryExt}}':
source: data/{{.BeatName}}-{{ commit_short }}/{{.BeatName}}{{.BinaryExt}}
symlink: true
mode: 0755
mode: 0755
6 changes: 6 additions & 0 deletions dev-tools/packaging/templates/deb/postinstall.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/sh

systemctl daemon-reload 2> /dev/null
systemctl is-active {{.BeatName}} --quiet && systemctl restart {{.BeatName}}
exit 0

0 comments on commit c0f53cf

Please sign in to comment.