Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd and packaging (RPM) improvments from discussion in #213 #212

Closed
wants to merge 11 commits into from
20 changes: 16 additions & 4 deletions pkg/rpm/rpmbuild/SOURCES/unit.service
@@ -1,14 +1,26 @@
# Modifying this file in-place is not recommended, because changes
# will be overwritten during package upgrades. To customize the
# behaviour, run "systemctl edit unit" to create an override unit.

# For example, to change options given to the unitd binary at startup,
# create an override unit (as is done by systemctl edit) and enter
# the following:

# [Service]
# Environment="UNITD_OPTIONS=--control unix:/run/unit/control.sock --log /var/log/unit/unit.log --pid /run/unit/unit.pid"

[Unit]
Description=NGINX Unit
Wants=network-online.target
After=network-online.target

[Service]
Type=forking
PIDFile=/run/unit.pid
EnvironmentFile=-/etc/sysconfig/unit
ExecStart=/usr/sbin/unitd $UNITD_OPTIONS
Type=simple
Environment="UNITD_OPTIONS=--control unix:/run/unit/control.sock --log /var/log/unit/unit.log --pid /run/unit/unit.pid"
ExecStart=/usr/sbin/unitd $UNITD_OPTIONS --no-daemon
ExecReload=
RuntimeDirectory=unit
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion pkg/rpm/rpmbuild/SOURCES/unit.sysconf
@@ -1 +1 @@
UNITD_OPTIONS="--log /var/log/unit.log --pid /run/unit.pid"
UNITD_OPTIONS="--control unix:/var/run/unit/control.sock --log /var/log/unit/unit.log --pid /var/run/unit/unit.pid"
29 changes: 21 additions & 8 deletions pkg/rpm/unit.spec.in
@@ -1,5 +1,5 @@
# distribution specific definitions
%define use_systemd (0%{?rhel} && 0%{?rhel} >= 7) || (0%{?suse_version} >= 1315)
%define use_systemd (0%{?rhel} >= 7 || 0%{?fedora} >= 19 || 0%{?suse_version} >= 1315)
%define bdir %{_builddir}/%{name}-%{version}
%define dotests 0

Expand All @@ -8,18 +8,24 @@ Requires: initscripts >= 8.36
BuildRequires: openssl-devel
%endif

%if 0%{?rhel} == 7
Requires: systemd
BuildRequires: systemd-units
%if %{use_systemd}
BuildRequires: systemd
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%endif

%if 0%{?rhel}%{?fedora}
BuildRequires: openssl-devel
%endif

%if 0%{?rhel}
%if 0%{?amzn} == 0
%define dist .el7
%define dist .el%{?rhel}
%endif
%endif

%if 0%{?suse_version} >= 1315
BuildRequires: systemd
Requires: systemd
BuildRequires: libopenssl-devel
%endif

Expand Down Expand Up @@ -103,9 +109,13 @@ DESTDIR=%{buildroot} make unitd-install libunit-install
%{__mkdir} -p %{buildroot}%{_libdir}/unit/modules
%{__mkdir} -p %{buildroot}%{_libdir}/unit/debug-modules
%{__mkdir} -p %{buildroot}%{_sharedstatedir}/unit
%{__mkdir} -p %{buildroot}%{_localstatedir}/log/unit
%{__mkdir} -p %{buildroot}%{_localstatedir}/run/unit
%if ! %{use_systemd}
%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
%{__install} -m 644 -p %{SOURCE3} \
%{buildroot}%{_sysconfdir}/sysconfig/unit
%endif
%{__mkdir} -p %{buildroot}%{_sysconfdir}/unit
%{__mkdir} -p %{buildroot}%{_datadir}/doc/unit/examples
%{__install} -m 644 -p %{SOURCE4} \
Expand Down Expand Up @@ -185,18 +195,21 @@ fi
%defattr(-,root,root,-)
%attr(0755,root,root) %{_sbindir}/unitd
%attr(0755,root,root) %{_sbindir}/unitd-debug
%config(noreplace) %{_sysconfdir}/sysconfig/unit
%dir %{_sysconfdir}/unit
%if %{use_systemd}
%{_unitdir}/unit.service
%dir %attr(0755,root,root) %ghost %{_localstatedir}/run/unit
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ghosted directory is enough, will be created during service startup by systemd

%else
%config(noreplace) %{_sysconfdir}/sysconfig/unit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@remicollet it seems like this one is mistakenly reverted here from
575d6d4 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nop, simply move lower (to avoid multiple conditions)

%dir %attr(0755,root,root) %{_localstatedir}/run/unit
%{_initrddir}/unit
%endif
%dir %{_datadir}/doc/unit
%{_datadir}/doc/unit/*
%dir %{_libdir}/unit/modules
%dir %{_libdir}/unit/debug-modules
%dir %{_sharedstatedir}/unit
%dir %attr(0700,root,root) %{_localstatedir}/log/unit

%files devel
%{_libdir}/libunit.a
Expand Down