Skip to content

Commit

Permalink
Release 1.4.1-1
Browse files Browse the repository at this point in the history
Summary:
* Various bug fixes
  • Loading branch information
Mike Belov committed Nov 6, 2018
1 parent cb7469a commit 7c2aa46
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 55 deletions.
4 changes: 2 additions & 2 deletions amplify/agent/common/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def __init__(self):

# define vars
self.cpu_last_check = 0
self.version_semver = (1, 4, 0)
self.version_build = 2
self.version_semver = (1, 4, 1)
self.version_build = 1
self.uuid = None
self.version = '%s-%s' % ('.'.join(map(str, self.version_semver)), self.version_build)
self.environment = None
Expand Down
6 changes: 6 additions & 0 deletions packages/nginx-amplify-agent/deb/DEBIAN/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
nginx-amplify-agent (1.4.1-1) stable; urgency=low

* Various bug fixes

-- Mike Belov <dedm@nginx.com> Thu, 26 Jul 2018 10:00:00 -0800

nginx-amplify-agent (1.4.0-1) stable; urgency=low

* New metrics for nginx, phpfpm, and mysql status
Expand Down
32 changes: 20 additions & 12 deletions packages/nginx-amplify-agent/deb/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
Package: nginx-amplify-agent
Description: NGINX Amplify Agent
The NGINX Amplify Agent is a small, Python application that provides
system and NGINX metric collection. It is part of NGINX Amplify -
the monitoring and configuration assistance service for NGINX.
.
This package installs and runs NGINX Amplify Agent daemon.
.
See http://nginx.com/amplify for more information
License: 2-clause BSD-like license
Source: nginx-amplify-agent
Homepage: https://github.com/nginxinc
Maintainer: Mike Belov <dedm@nginx.com>
Section: python
Priority: optional
Version: 0.0-0
Build-Depends: debhelper (>= 9~),
dh-systemd,
dpkg-dev (>= 1.16.1~)
Standards-Version: 3.9.8.0

Package: nginx-amplify-agent
Description: NGINX Amplify Agent
The NGINX Amplify Agent is a small, Python application that provides
system and NGINX metric collection. It is part of NGINX Amplify -
the monitoring and configuration assistance service for NGINX.
.
This package installs and runs NGINX Amplify Agent daemon.
.
See http://nginx.com/amplify for more information
Architecture: any
Depends: python (>=2.6), lsb-release
Depends: ${misc:Depends},
${shlibs:Depends},
python (>=2.6),
lsb-release,
adduser
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=NGINX Amplify Agent
Documentation=https://amplify.nginx.com/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
User=nginx
Group=nginx
Type=forking
PIDFile=/var/run/amplify-agent/amplify-agent.pid
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/run/amplify-agent
ExecStartPre=/bin/chown nginx /var/run/amplify-agent
ExecStartPre=/bin/chown nginx /etc/amplify-agent/agent.conf
ExecStartPre=/bin/chown nginx /var/log/amplify-agent/agent.log
ExecStart=/usr/bin/nginx-amplify-agent.py start --config=/etc/amplify-agent/agent.conf --pid=/var/run/amplify-agent/amplify-agent.pid
ExecStop=/usr/bin/nginx-amplify-agent.py stop --config=/etc/amplify-agent/agent.conf --pid=/var/run/amplify-agent/amplify-agent.pid

[Install]
WantedBy=multi-user.target
3 changes: 2 additions & 1 deletion packages/nginx-amplify-agent/deb/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ if [ "$1" != "configure" ]; then
fi

if [ -z "$2" ]; then
update-rc.d amplify-agent defaults 99 01
mkdir -p /var/run/amplify-agent && \
mkdir -p /var/log/amplify-agent && \
touch /var/log/amplify-agent/agent.log && \
Expand Down Expand Up @@ -50,3 +49,5 @@ else
service amplify-agent start > /dev/null 2>&1 < /dev/null
fi
fi

#DEBHELPER#
15 changes: 15 additions & 0 deletions packages/nginx-amplify-agent/deb/DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -e

case "$1" in
purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
;;
*)
echo "postrm called with unknown argument \`$1'" >&2
exit 1
esac

#DEBHELPER#

exit 0
9 changes: 4 additions & 5 deletions packages/nginx-amplify-agent/deb/DEBIAN/prerm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ case "$1" in
remove)
service amplify-agent stop

if [ -e /etc/init.d/amplify-agent ]; then
rm /etc/init.d/amplify-agent
update-rc.d -f amplify-agent remove
fi

[ -d /var/log/amplify-agent ] && rm -R /var/log/amplify-agent
[ -d /var/run/amplify-agent ] && rm -R /var/run/amplify-agent
[ -d /etc/amplify-agent ] && rm -R /etc/amplify-agent
Expand All @@ -27,3 +22,7 @@ case "$1" in
exit 0
;;
esac

#DEBHELPER#

exit 0
41 changes: 39 additions & 2 deletions packages/nginx-amplify-agent/deb/DEBIAN/rules
Original file line number Diff line number Diff line change
@@ -1,4 +1,41 @@
#!/usr/bin/make -f

%:
dh $@ --with=python-central
INSTALLDIR = $(CURDIR)/debian/nginx-amplify-agent

build-arch:
dh_testdir

build-indep:
dh_testdir

build: build-arch build-indep
dh_testdir

install:
dh_testdir

binary-indep: build install
dh_testdir
dh_installdebconf
dh_installinit -i -pnginx-amplify-agent --no-restart-on-upgrade --no-start --name=amplify-agent -- defaults 99 01
dh_systemd_enable -pnginx-amplify-agent --name=amplify-agent amplify-agent.service

binary-arch: install
dh_testdir
dh_testroot
dh_installchangelogs -a
dh_installdocs -a
dh_lintian -a
dh_link -aA
dh_compress -a
dh_fixperms -a
dh_installdeb -a
dh_shlibdeps -a
dh_gencontrol -a
dh_md5sums -a
dh_builddeb nginx-amplify-agent

binary: binary-indep binary-arch

clean:
dh_testdir
21 changes: 21 additions & 0 deletions packages/nginx-amplify-agent/rpm/nginx-amplify-agent.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[Unit]
Description=NGINX Amplify Agent
Documentation=https://amplify.nginx.com/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
User=nginx
Group=nginx
Type=forking
PIDFile=/var/run/amplify-agent/amplify-agent.pid
PermissionsStartOnly=true
ExecStartPre=/bin/mkdir -p /var/run/amplify-agent
ExecStartPre=/bin/chown nginx /var/run/amplify-agent
ExecStartPre=/bin/chown nginx /etc/amplify-agent/agent.conf
ExecStartPre=/bin/chown nginx /var/log/amplify-agent/agent.log
ExecStart=/usr/bin/nginx-amplify-agent.py start --config=/etc/amplify-agent/agent.conf --pid=/var/run/amplify-agent/amplify-agent.pid
ExecStop=/usr/bin/nginx-amplify-agent.py stop --config=/etc/amplify-agent/agent.conf --pid=/var/run/amplify-agent/amplify-agent.pid

[Install]
WantedBy=multi-user.target
21 changes: 19 additions & 2 deletions packages/nginx-amplify-agent/rpm/nginx-amplify-agent.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}

# distribution specific definitions
%define use_systemd (0%{?fedora} && 0%{?fedora} >= 18) || (0%{?rhel} && 0%{?rhel} >= 7) || (0%{?suse_version} == 1315)
%define use_systemd (0%{?fedora} && 0%{?fedora} >= 18) || (0%{?rhel} && 0%{?rhel} >= 7) || (0%{?suse_version} == 1315) || (0%{?amzn} >= 2)

%define nginx_home %{_localstatedir}/cache/nginx
%define nginx_user nginx
Expand All @@ -20,9 +20,12 @@ License: 2-clause BSD-like license


Source0: nginx-amplify-agent-%{version}.tar.gz
%if %{use_systemd}
Source1: nginx-amplify-agent.service
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

%if 0%{?amzn}
%if (0%{?amzn} == 1)
Requires: python27
%else
Requires: python >= 2.6
Expand Down Expand Up @@ -69,6 +72,11 @@ mkdir -p %{buildroot}/var/log/amplify-agent/
mkdir -p %{buildroot}/var/
mkdir -p %{buildroot}/var/run/
mkdir -p %{buildroot}/var/run/amplify-agent/
%if %{use_systemd}
%{__mkdir} -p %{buildroot}/%{_unitdir}
%{__install} -m644 %SOURCE1 %{buildroot}/%{_unitdir}/amplify-agent.service
rm -rf %{buildroot}/etc/init.d
%endif


%clean
Expand All @@ -83,7 +91,11 @@ mkdir -p %{buildroot}/var/run/amplify-agent/
%{config_files}/*
%attr(0755,nginx,nginx) %dir /var/log/amplify-agent
%attr(0755,nginx,nginx) %dir /var/run/amplify-agent
%if %{use_systemd}
%{_unitdir}/amplify-agent.service
%else
/etc/init.d/amplify-agent
%endif
/etc/logrotate.d/amplify-agent


Expand All @@ -93,6 +105,7 @@ mkdir -p %{buildroot}/var/run/amplify-agent/
if [ $1 -eq 1 ] ; then
%if %{use_systemd}
/usr/bin/systemctl preset amplify-agent.service >/dev/null 2>&1 ||:
/usr/bin/systemctl enable amplify-agent.service >/dev/null 2>&1 ||:
%else
/sbin/chkconfig --add amplify-agent
%endif
Expand Down Expand Up @@ -149,6 +162,10 @@ fi


%changelog
* Thu Jul 26 2018 Mike Belov <dedm@nginx.com> 1.4.1-1
- 1.4.1-1
- Various bug fixes

* Thu Jul 26 2018 Grant Hulegaard <grant.hulegaard@nginx.com> 1.4.0-1
- 1.4.0-1
- New metrics for nginx, phpfpm, and mysql status
Expand Down
2 changes: 1 addition & 1 deletion packages/nginx-amplify-agent/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

setup(
name="nginx-amplify-agent",
version="1.4.0",
version="1.4.1",
author="Mike Belov",
author_email="dedm@nginx.com",
description="NGINX Amplify Agent",
Expand Down
2 changes: 1 addition & 1 deletion packages/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.0-1
1.4.1-1
2 changes: 1 addition & 1 deletion tools/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
else:
os_release = shell_call('cat /etc/os-release', important=False)

if 'amazon linux ami' in os_release.lower():
if 'amazon linux' in os_release.lower():
amazon.build(package=package)
else:
print("sorry, it will be done later\n")
9 changes: 6 additions & 3 deletions tools/builders/amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def build(package=None):
rpm_topdir = os.path.expanduser('~') + '/rpmbuild'
rpm_sources = rpm_topdir + '/SOURCES'
python = '/usr/bin/python2.7'
amzn = shell_call('rpm --eval "%{amzn}"')

# get version and build
version, bld = get_version_and_build()
Expand Down Expand Up @@ -55,9 +56,10 @@ def build(package=None):
# remove weird file
shell_call('rm -rf setup.cfg', important=False)

# provide a new one - to create a package that will work with the strange amazon linux rpm
shell_call("echo '[install]' > setup.cfg")
shell_call("echo 'install_lib = /usr/lib/python2.7/dist-packages' >> setup.cfg")
if amzn == 1:
# provide a new one - to create a package that will work with the strange amazon linux rpm
shell_call("echo '[install]' > setup.cfg")
shell_call("echo 'install_lib = /usr/lib/python2.7/dist-packages' >> setup.cfg")

# create python package
shell_call('cp packages/%s/setup.py ./' % package)
Expand All @@ -67,6 +69,7 @@ def build(package=None):
shell_call('cp -r dist/*.gz %s/' % rpm_sources)

# create rpm package
shell_call('cp packages/%s/rpm/%s.service %s' % (package, package, rpm_sources))
shell_call(
'rpmbuild -D "_topdir %s" -bb packages/%s/rpm/%s.spec --define "amplify_version %s" --define "amplify_release %s"' % (
rpm_topdir, package, package, version, bld
Expand Down
34 changes: 9 additions & 25 deletions tools/builders/deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ def build(package=None):
# get version and build
version, bld = get_version_and_build()

# get architecture
arch = shell_call("dpkg-architecture -c 'echo ${DEB_BUILD_ARCH}'").split('\n')[0]

# get codename
shell_call("lsb_release -c") # checks that lsb_release is installed
codename = shell_call("lsb_release -c | awk '{print $2}'").split('\n')[0]
codename = shell_call("lsb_release -cs").rstrip('\n')

# install pip
install_pip()
Expand All @@ -41,32 +37,20 @@ def build(package=None):
# install all dependencies
install_pip_deps(package=package)

# sed build to control
shell_call(
"sed -i 's/^Version: .*$/Version: %s-%s~%s/' packages/%s/deb/DEBIAN/control" % (
version, bld, codename, package
)
)
shell_call(
"sed -i 's/^Architecture: .*$/Architecture: %s/' packages/%s/deb/DEBIAN/control" % (
arch, package
)
)

# sed first line of changelog
changelog_first_line = '%s (%s-%s~%s) unstable; urgency=low' % (package, version, bld, codename)
change_first_line('packages/%s/deb/DEBIAN/changelog' % package, changelog_first_line)

# create python package
shell_call('cp packages/%s/setup.py ./' % package)
shell_call('python setup.py install --install-layout=deb --prefix=/usr --root=%s' % pkg_root)
shell_call('python setup.py install --install-layout=deb --prefix=/usr --root=%s/%s-%s/debian/%s' % (pkg_root, package, version, package))

# copy debian files to pkg-root
shell_call('cp -r packages/%s/deb/DEBIAN %s/' % (package, pkg_root))
shell_call('cp -r packages/%s/deb/debian %s/%s-%s/' % (package, pkg_root, package, version))

# sed first line of changelog
changelog_first_line = '%s (%s-%s~%s) %s; urgency=low' % (package, version, bld, codename, codename)
change_first_line('%s/%s-%s/debian/changelog' % (pkg_root, package, version), changelog_first_line)

# create deb package
package_file = '%s_%s-%s~%s_%s.deb' % (package, version, bld, codename, arch)
shell_call('fakeroot dpkg --build %s %s/%s' % (pkg_root, pkg_final, package_file))
shell_call('cd %s/%s-%s && debuild -us -uc' % (pkg_root, package, version), terminal=True)
shell_call('cp %s/*.deb %s/' % (pkg_root, pkg_final))

# clean
shell_call('rm -r build', important=False)
Expand Down
1 change: 1 addition & 0 deletions tools/builders/rpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def build(package=None):
shell_call('cp -r dist/*.gz %s/' % rpm_sources)

# create rpm package
shell_call('cp packages/%s/rpm/%s.service %s' % (package, package, rpm_sources))
shell_call(
'rpmbuild -D "_topdir %s" -bb packages/%s/rpm/%s.spec --define "amplify_version %s" --define "amplify_release %s"' % (
rpm_topdir, package, package, version, bld
Expand Down

0 comments on commit 7c2aa46

Please sign in to comment.