Skip to content

Commit 0ec1e18

Browse files
authored
Update agent version to 1.8.3 (#119)
* Update agent version to 1.8.3 Changes: - amplify.agent.common.runner migrated to latest PEP 3143 implementation, - added support for packaging Ubuntu 24.04 "noble", - fixed package building for RHEL 9. * packages: fixed issues found by internal CI
1 parent 0b04168 commit 0ec1e18

File tree

16 files changed

+112
-18
lines changed

16 files changed

+112
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
The NGINX Amplify Agent is a Python application that provides system and NGINX metric collection. It is part of NGINX Amplify — a free configuration monitoring tool for NGINX.
44

5-
Please check the list of the supported operating systems [here](https://docs.nginx.com/amplify/faq/nginx-amplify-agent/#what-operating-systems-are-supported).
5+
Please check the list of the supported operating systems [here](https://docs.nginx.com/nginx-amplify/faq/nginx-amplify-agent/#what-operating-systems-are-supported).
66

7-
This repository is not for installation purposes. To install the agent, please follow [this](https://docs.nginx.com/amplify/nginx-amplify-agent/install/installing-amplify-agent/) document.
7+
This repository is not for installation purposes. To install the agent, please follow [this](https://docs.nginx.com/nginx-amplify/nginx-amplify-agent/install/installing-amplify-agent/) document.
88

99
For more information about NGINX Amplify, please check the official documentation [here](https://docs.nginx.com/nginx-amplify/).

amplify/agent/common/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def __init__(self):
3737

3838
# define vars
3939
self.cpu_last_check = 0
40-
self.version_semver = (1, 8, 2)
40+
self.version_semver = (1, 8, 3)
4141
self.version_build = 1
4242
self.uuid = None
4343
self.version = '%s-%s' % ('.'.join(map(str, self.version_semver)), self.version_build)

amplify/agent/common/runner.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
# -*- coding: utf-8 -*-
22
import signal
33

4-
from daemon import runner
4+
import daemon
5+
from daemon.pidfile import PIDLockFile
56

67
from amplify.agent.common.context import context
78

89
__author__ = "Mike Belov"
910
__copyright__ = "Copyright (C) Nginx, Inc. All rights reserved."
1011
__license__ = ""
11-
__maintainer__ = "Mike Belov"
12-
__email__ = "dedm@nginx.com"
12+
__maintainer__ = "Andrei Belov"
13+
__email__ = "a.belov@f5.com"
1314

1415

15-
class Runner(runner.DaemonRunner):
16+
class Runner:
1617
def __init__(self, app):
17-
super(Runner, self).__init__(app)
18-
1918
def cleanup(signum, frame):
2019
app.stop()
2120

21+
self.daemon_context = daemon.DaemonContext()
22+
2223
self.app = app
2324
self.daemon_context.detach_process = True
25+
self.daemon_context.pidfile = PIDLockFile('/var/run/amplify-agent/amplify-agent.pid')
2426
self.daemon_context.files_preserve = context.get_file_handlers()
2527
self.daemon_context.signal_map = {
2628
signal.SIGTERM: cleanup
2729
}
30+
self._open_streams_from_app_stream_paths(app)
2831

2932
def _open_streams_from_app_stream_paths(self, app):
3033
self.daemon_context.stdin = open(app.stdin_path, 'rt')
3134
self.daemon_context.stdout = open(app.stdout_path, 'w+t')
3235
self.daemon_context.stderr = open(app.stderr_path, 'w+t')
36+
37+
def do_action(self):
38+
"""
39+
Stub function to mock old DaemonRunner behavior
40+
"""
41+
with self.daemon_context:
42+
self.app.run()

etc/chkconfig/amplify-agent

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,19 @@ start() {
7575
chown -f $user /etc/amplify-agent/agent.conf
7676
chown -f $user /var/log/amplify-agent/agent.log
7777
daemon --user=$user $binary start --config=$conffile --pid=$pidfile
78-
fi;
78+
fi
79+
RETVAL="$?"
7980
echo
80-
return $RETVAL
81+
if [ "$RETVAL" -ne 0 ]; then
82+
return "$RETVAL"
83+
fi
84+
for i in 1 2 3 4 5; do
85+
if [ -e "$pidfile" ]; then
86+
return 0
87+
fi
88+
sleep 1
89+
done
90+
return 1
8191
}
8292

8393
stop() {
@@ -123,6 +133,13 @@ debug() {
123133

124134
case "$1" in
125135
start)
136+
if status -p $pidfile amplify-agent >/dev/null 2>&1; then
137+
echo "amplify-agent is already running" >&2
138+
exit 0
139+
fi
140+
if [ -e "$pidfile" ]; then
141+
rm -f "$pidfile"
142+
fi
126143
start
127144
RETVAL=$?
128145
;;
@@ -135,7 +152,7 @@ case "$1" in
135152
RETVAL=$?
136153
;;
137154
status)
138-
status -p $pidfile amplify-agent
155+
status -p $pidfile amplify-agent
139156
RETVAL=$?
140157
;;
141158
configtest)

etc/init.d/amplify-agent

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,16 @@ do_start()
6666
chown -f $USER /var/log/amplify-agent/agent.log
6767
start-stop-daemon --start --chuid $USER --exec $DAEMON start -- $DAEMON_ARGS
6868
RETVAL="$?"
69-
return "$RETVAL"
69+
if [ "$RETVAL" -ne 0 ]; then
70+
return "$RETVAL"
71+
fi
72+
for i in 1 2 3 4 5; do
73+
if [ -e "$PIDFILE" ]; then
74+
return 0
75+
fi
76+
sleep 1
77+
done
78+
return 1
7079
}
7180

7281
do_stop()
@@ -94,6 +103,13 @@ do_debug() {
94103

95104
case "$1" in
96105
start)
106+
if status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" >/dev/null 2>&1; then
107+
echo " * $NAME is already running" >&2
108+
exit 0
109+
fi
110+
if [ -e "$PIDFILE" ]; then
111+
rm -f "$PIDFILE"
112+
fi
97113
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
98114
do_start
99115
case "$?" in

packages/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ case "$os" in
467467
incr_step
468468

469469
case "$codename" in
470-
buster|bullseye|bookworm|bionic|focal|jammy)
470+
buster|bullseye|bookworm|bionic|focal|jammy|noble)
471471
check_python 3
472472
python_supported=3
473473
;;

packages/nginx-amplify-agent/deb/debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
nginx-amplify-agent (1.8.3-1) stable; urgency=low
2+
3+
* migrated to the most recent daemonizing logic (PEP 3143)
4+
5+
-- Andrei Belov <a.belov@f5.com> Wed, 8 Jan 2025 16:08:40 +0400
6+
17
nginx-amplify-agent (1.8.2-1) stable; urgency=low
28

39
* pyMySQL updated to 1.1.1
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Source: nginx-amplify-agent
2+
Homepage: https://github.com/nginxinc/nginx-amplify-agent
3+
Maintainer: NGINX Packaging <nginx-packaging@f5.com>
4+
Section: python
5+
Priority: optional
6+
Build-Depends: debhelper (>= 13),
7+
dpkg-dev (>= 1.22),
8+
python3,
9+
dh-python
10+
Standards-Version: 4.5.0
11+
12+
Package: nginx-amplify-agent
13+
Description: Agent for NGINX Amplify monitoring platform
14+
The NGINX Amplify Agent is a small, Python application that provides
15+
system and NGINX metric collection. It is part of NGINX Amplify -
16+
the monitoring and configuration assistance service for NGINX.
17+
.
18+
This package installs and runs NGINX Amplify Agent daemon.
19+
.
20+
See http://nginx.com/amplify for more information
21+
Architecture: any
22+
Depends: ${misc:Depends},
23+
${python3:Depends},
24+
python3-daemon,
25+
python3-pyasyncore,
26+
python3-setproctitle,
27+
python3-greenlet,
28+
python3-gevent,
29+
python3-requests,
30+
python3-ujson,
31+
python3-netifaces,
32+
python3-pymysql,
33+
python3-psutil,
34+
lsb-release,
35+
adduser

packages/nginx-amplify-agent/requirements-rhel9.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ rstr==3.0.0
77
python-daemon==2.2.4
88
ujson==5.4.0
99
PyMySQL==1.1.1
10+
setuptools<=70.3.0
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
netaddr==0.8.0
2+
flup==1.0.3
3+
crossplane==0.5.8
4+
rstr==3.0.0

0 commit comments

Comments
 (0)