Skip to contentSkip to conversation

nginx: optimize systemd unit file

PATCH Superseded Szombathelyi György 3 participants 8 messages Aug 18, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nginx: optimize systemd unit file

- Call the nginx binary directly, no need to
wrap the SysV init file.
- Create /var/log/nginx with tmpfiles, like volatiles without systemd.
- Run nginx with ${NGINX_USER} (user ${NGINX_USER} in nginx.conf)

meta- renamed from meta-webserver/recipes-httpd/nginx/files/nginx.service +0 -0

webserver/recipes-httpd/nginx/files/nginx.service
index 9926a4b..ce99061 100644

meta-webserver/recipes-httpd/nginx/files/nginx.service +4 -5
@@ -3,10 +3,9 @@ Description=Nginx Server
 After=network.target
 [Service]
 Type=forking
-PIDFile=@SYSCONFDIR@/nginx/run/nginx.pid
-ExecStartPre=@BASEBINDIR@/mkdir -p @LOCALSTATEDIR@/log/nginx
-ExecStart=@SYSCONFDIR@/init.d/nginx start
-ExecStop=@SYSCONFDIR@/init.d/nginx stop
+PIDFile=/run/nginx/nginx.pid
+ExecStart=@SBINDIR@/nginx
+ExecStop=@SBINDIR@/nginx -s stop
+ExecReload=@SBINDIR@/nginx -s reload
 [Install]
 WantedBy=multi-user.target
-
meta-webserver/ renamed from meta-webserver/recipes-httpd/nginx/nginx.inc +0 -0

recipes-httpd/nginx/nginx.inc
index fe51ca0..25ac7a4 100644

meta-webserver/recipes-httpd/nginx/nginx.inc +3 -0
@@ -75,6 +75,9 @@ do_install () {
                install -d ${D}${sysconfdir}/tmpfiles.d
                echo "d /run/${BPN} - - - -" \
                     > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
+                echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
+                     >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
+
        fi
        install -d ${D}${sysconfdir}/${BPN}
        ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
@@ -90,6 +93,7 @@ do_install () {
        install -d ${D}${sysconfdir}/nginx
        install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/

nginx.conf

        sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/
nginx.conf
+       sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/
nginx.conf
        install -d ${D}${sysconfdir}/nginx/sites-enabled
 
        install -d ${D}${sysconfdir}/default/volatiles
@@ -101,7 +105,7 @@ do_install () {
             install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/
system/
             sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
                     -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
-                    -e 's,@BASEBINDIR@,${base_bindir},g' \
+                    -e 's,@SBINDIR@,${sbindir},g' \
                     ${D}${systemd_unitdir}/system/nginx.service
         fi

}

#1 lore raw
Quoted 47 lines · Szombathelyi György

- Call the nginx binary directly, no need to
wrap the SysV init file.
- Create /var/log/nginx with tmpfiles, like volatiles without systemd.
- Run nginx with ${NGINX_USER} (user ${NGINX_USER} in nginx.conf)

meta- renamed from meta-webserver/recipes-httpd/nginx/files/nginx.service +0 -0

webserver/recipes-httpd/nginx/files/nginx.service
index 9926a4b..ce99061 100644

meta-webserver/recipes-httpd/nginx/files/nginx.service +4 -5
@@ -3,10 +3,9 @@ Description=Nginx Server
 After=network.target
 [Service]
 Type=forking
-PIDFile=@SYSCONFDIR@/nginx/run/nginx.pid
-ExecStartPre=@BASEBINDIR@/mkdir -p @LOCALSTATEDIR@/log/nginx
-ExecStart=@SYSCONFDIR@/init.d/nginx start
-ExecStop=@SYSCONFDIR@/init.d/nginx stop
+PIDFile=/run/nginx/nginx.pid
+ExecStart=@SBINDIR@/nginx
+ExecStop=@SBINDIR@/nginx -s stop
+ExecReload=@SBINDIR@/nginx -s reload
 [Install]
 WantedBy=multi-user.target
-
meta-webserver/ renamed from meta-webserver/recipes-httpd/nginx/nginx.inc +0 -0

recipes-httpd/nginx/nginx.inc
index fe51ca0..25ac7a4 100644

meta-webserver/recipes-httpd/nginx/nginx.inc +3 -0
@@ -75,6 +75,9 @@ do_install () {
                install -d ${D}${sysconfdir}/tmpfiles.d
                echo "d /run/${BPN} - - - -" \
                     > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
+                echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
+                     >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
+
        fi
        install -d ${D}${sysconfdir}/${BPN}
        ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
@@ -90,6 +93,7 @@ do_install () {
        install -d ${D}${sysconfdir}/nginx
        install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/

nginx.conf

Quoted 5 lines
        sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/
nginx.conf
+       sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/
nginx.conf
        install -d ${D}${sysconfdir}/nginx/sites-enabled

Please fix your sender to stop wrapping long lines.

OE @ ~/meta-openembedded $ pwam 129537
2016-08-18 17:58:48 URL:https://patchwork.openembedded.org/patch/129537/mbox/ [3015] -> "pw-am-129537.patch" [1]
Applying: nginx: optimize systemd unit file
fatal: corrupt patch at line 41
Patch failed at 0001 nginx: optimize systemd unit file
The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".

Quoted 17 lines
        install -d ${D}${sysconfdir}/default/volatiles
meta-webserver/recipes-httpd/nginx/nginx.inc +0 -0
@@ -101,7 +105,7 @@ do_install () {
             install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/

system/

             sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
                     -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
meta-webserver/recipes-httpd/nginx/nginx.inc +1 -1
-                    -e 's,@BASEBINDIR@,${base_bindir},g' \
+                    -e 's,@SBINDIR@,${sbindir},g' \
                     ${D}${systemd_unitdir}/system/nginx.service
         fi
 }
Signature · 5 lines
-- 
_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
Signature · 1 line
Martin 'JaMa' Jansa     jabber: [email protected]
#2 lore raw

PATCH v2 1/2 nginx: optimize systemd unit file

From: Szombathelyi György <[email protected]>

- Call the nginx binary directly, no need to wrap the SysV init file.
- Create /var/log/nginx with tmpfiles, like volatiles without systemd.
- Run nginx with ${NGINX_USER} (user ${NGINX_USER} in nginx.conf)

---
 meta-webserver/recipes-httpd/nginx/files/nginx.service | 9 ++++-----
 meta-webserver/recipes-httpd/nginx/nginx.inc           | 5 +++--
 2 files changed, 7 insertions(+), 7 deletions(-)
meta-webserver/recipes-httpd/nginx/files/nginx.service +4 -5
index 9926a4b..ce99061 100644
@@ -3,10 +3,9 @@ Description=Nginx Server
 After=network.target
 [Service]
 Type=forking
-PIDFile=@SYSCONFDIR@/nginx/run/nginx.pid
-ExecStartPre=@BASEBINDIR@/mkdir -p @LOCALSTATEDIR@/log/nginx
-ExecStart=@SYSCONFDIR@/init.d/nginx start
-ExecStop=@SYSCONFDIR@/init.d/nginx stop
+PIDFile=/run/nginx/nginx.pid
+ExecStart=@SBINDIR@/nginx
+ExecStop=@SBINDIR@/nginx -s stop
+ExecReload=@SBINDIR@/nginx -s reload
 [Install]
 WantedBy=multi-user.target
-
meta-webserver/recipes-httpd/nginx/nginx.inc +3 -2
index fe51ca0..334a6d8 100644
@@ -73,8 +73,8 @@ do_install () {
 	rm -fr ${D}${localstatedir}/run ${D}/run
 	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
 		install -d ${D}${sysconfdir}/tmpfiles.d
-		echo "d /run/${BPN} - - - -" \
-		     > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
+		echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
+			>> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
 	fi
 	install -d ${D}${sysconfdir}/${BPN}
 	ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
@@ -90,6 +90,7 @@ do_install () {
 	install -d ${D}${sysconfdir}/nginx
 	install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
 	sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
+	sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf
 	install -d ${D}${sysconfdir}/nginx/sites-enabled
 
 	install -d ${D}${sysconfdir}/default/volatiles
Signature · 1 line
2.9.2
#3 lore raw

PATCH v2 2/2 nginx.inc: use 4 spaces for indentation

* like any other sane recipes do

---
 meta-webserver/recipes-httpd/nginx/nginx.inc | 190 ++++++++++++++-------------
 1 file changed, 96 insertions(+), 94 deletions(-)
meta-webserver/recipes-httpd/nginx/nginx.inc +96 -94
index 334a6d8..39ca771 100644
@@ -12,12 +12,12 @@ SECTION = "net"
 DEPENDS = "libpcre gzip openssl"
 
 SRC_URI = " \
-	http://nginx.org/download/nginx-${PV}.tar.gz \
-	file://nginx-cross.patch \
-	file://nginx.conf \
-	file://nginx.init \
-	file://nginx-volatile.conf \
-	file://nginx.service \
+    http://nginx.org/download/nginx-${PV}.tar.gz \
+    file://nginx-cross.patch \
+    file://nginx.conf \
+    file://nginx.init \
+    file://nginx-volatile.conf \
+    file://nginx.service \
 "
 
 inherit update-rc.d useradd
@@ -34,102 +34,104 @@ DISABLE_STATIC = ""
 PACKAGECONFIG[http2] = "--with-http_v2_module,,"
 
 do_configure () {
-	if [ "${SITEINFO_BITS}" = "64" ]; then
-		PTRSIZE=8
-	else
-		PTRSIZE=4
-	fi
-
-	echo $CFLAGS
-	echo $LDFLAGS
-
-	# Add the LDFLAGS to the main nginx link to avoid issues with missing GNU_HASH
-	echo "MAIN_LINK=\"\${MAIN_LINK} ${LDFLAGS}\"" >> auto/cc/conf
-
-	./configure \
-	--crossbuild=Linux:${TUNE_ARCH} \
-	--with-endian=${@base_conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \
-	--with-int=4 \
-	--with-long=${PTRSIZE} \
-	--with-long-long=8 \
-	--with-ptr-size=${PTRSIZE} \
-	--with-sig-atomic-t=${PTRSIZE} \
-	--with-size-t=${PTRSIZE} \
-	--with-off-t=${PTRSIZE} \
-	--with-time-t=${PTRSIZE} \
-	--with-sys-nerr=132 \
-	--conf-path=${sysconfdir}/nginx/nginx.conf \
-	--http-log-path=${localstatedir}/log/nginx/access.log \
-	--error-log-path=${localstatedir}/log/nginx/error.log \
-	--pid-path=/run/nginx/nginx.pid \
-	--prefix=${prefix} \
-	--with-http_ssl_module \
-	--with-http_gzip_static_module \
-	${EXTRA_OECONF}
+    if [ "${SITEINFO_BITS}" = "64" ]; then
+        PTRSIZE=8
+    else
+        PTRSIZE=4
+    fi
+
+    echo $CFLAGS
+    echo $LDFLAGS
+
+    # Add the LDFLAGS to the main nginx link to avoid issues with missing GNU_HASH
+    echo "MAIN_LINK=\"\${MAIN_LINK} ${LDFLAGS}\"" >> auto/cc/conf
+
+    ./configure \
+    --crossbuild=Linux:${TUNE_ARCH} \
+    --with-endian=${@base_conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \
+    --with-int=4 \
+    --with-long=${PTRSIZE} \
+    --with-long-long=8 \
+    --with-ptr-size=${PTRSIZE} \
+    --with-sig-atomic-t=${PTRSIZE} \
+    --with-size-t=${PTRSIZE} \
+    --with-off-t=${PTRSIZE} \
+    --with-time-t=${PTRSIZE} \
+    --with-sys-nerr=132 \
+    --conf-path=${sysconfdir}/nginx/nginx.conf \
+    --http-log-path=${localstatedir}/log/nginx/access.log \
+    --error-log-path=${localstatedir}/log/nginx/error.log \
+    --pid-path=/run/nginx/nginx.pid \
+    --prefix=${prefix} \
+    --with-http_ssl_module \
+    --with-http_gzip_static_module \
+    ${EXTRA_OECONF}
 }
 
 do_install () {
-	oe_runmake 'DESTDIR=${D}' install
-	rm -fr ${D}${localstatedir}/run ${D}/run
-	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
-		install -d ${D}${sysconfdir}/tmpfiles.d
-		echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
-			>> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
-	fi
-	install -d ${D}${sysconfdir}/${BPN}
-	ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
-	install -d ${D}${NGINX_WWWDIR}
-	mv ${D}/usr/html ${D}${NGINX_WWWDIR}/
-	chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR}
-
-	install -d ${D}${sysconfdir}/init.d
-	install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx
-	sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx
-	sed -i 's,/etc/,${sysconfdir}/,g'  ${D}${sysconfdir}/init.d/nginx
-
-	install -d ${D}${sysconfdir}/nginx
-	install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
-	sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
-	sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf
-	install -d ${D}${sysconfdir}/nginx/sites-enabled
-
-	install -d ${D}${sysconfdir}/default/volatiles
-	install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx
-	sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx
-
-        if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
-            install -d ${D}${systemd_unitdir}/system
-            install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/
-            sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
-                    -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
-                    -e 's,@BASEBINDIR@,${base_bindir},g' \
-                    ${D}${systemd_unitdir}/system/nginx.service
-        fi
+    oe_runmake 'DESTDIR=${D}' install
+    rm -fr ${D}${localstatedir}/run ${D}/run
+    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+        install -d ${D}${sysconfdir}/tmpfiles.d
+        echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
+            >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
+    fi
+    install -d ${D}${sysconfdir}/${BPN}
+    ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
+    install -d ${D}${NGINX_WWWDIR}
+    mv ${D}/usr/html ${D}${NGINX_WWWDIR}/
+    chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR}
+
+    install -d ${D}${sysconfdir}/init.d
+    install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx
+    sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx
+    sed -i 's,/etc/,${sysconfdir}/,g'  ${D}${sysconfdir}/init.d/nginx
+
+    install -d ${D}${sysconfdir}/nginx
+    install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
+    sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
+    sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf
+    install -d ${D}${sysconfdir}/nginx/sites-enabled
+
+    install -d ${D}${sysconfdir}/default/volatiles
+    install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx
+    sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx
+
+    if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
+        install -d ${D}${systemd_unitdir}/system
+        install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/
+        sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
+            -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
+            -e 's,@BASEBINDIR@,${base_bindir},g' \
+            ${D}${systemd_unitdir}/system/nginx.service
+    fi
 }
 
 pkg_postinst_${PN} () {
-	if [ -z "$D" ]; then
-		if type systemd-tmpfiles >/dev/null; then
-			systemd-tmpfiles --create
-		elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
-			${sysconfdir}/init.d/populate-volatile.sh update
-		fi
-	fi
+    if [ -z "$D" ]; then
+        if type systemd-tmpfiles >/dev/null; then
+            systemd-tmpfiles --create
+        elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
+            ${sysconfdir}/init.d/populate-volatile.sh update
+        fi
+    fi
 }
 
-FILES_${PN} += "${localstatedir}/ \
-                ${systemd_unitdir}/system/nginx.service \
-                "
-
-CONFFILES_${PN} = "${sysconfdir}/nginx/nginx.conf \
-		${sysconfdir}/nginx/fastcgi.conf\
-		${sysconfdir}/nginx/fastcgi_params \
-		${sysconfdir}/nginx/koi-utf \
-		${sysconfdir}/nginx/koi-win \
-		${sysconfdir}/nginx/mime.types \
-		${sysconfdir}/nginx/scgi_params \
-		${sysconfdir}/nginx/uwsgi_params \
-		${sysconfdir}/nginx/win-utf \
+FILES_${PN} += " \
+    ${localstatedir}/ \
+    ${systemd_unitdir}/system/nginx.service \
+"
+
+CONFFILES_${PN} = " \
+    ${sysconfdir}/nginx/nginx.conf \
+    ${sysconfdir}/nginx/fastcgi.conf \
+    ${sysconfdir}/nginx/fastcgi_params \
+    ${sysconfdir}/nginx/koi-utf \
+    ${sysconfdir}/nginx/koi-win \
+    ${sysconfdir}/nginx/mime.types \
+    ${sysconfdir}/nginx/scgi_params \
+    ${sysconfdir}/nginx/uwsgi_params \
+    ${sysconfdir}/nginx/win-utf \
 "
 
 INITSCRIPT_NAME = "nginx"
Signature · 1 line
2.9.2
#4 lore raw
In reply to Martin Jansa

Op 18-08-16 om 18:09 schreef Martin Jansa:

Quoted 7 lines

From: Szombathelyi György <[email protected]>

- Call the nginx binary directly, no need to wrap the SysV init file.
- Create /var/log/nginx with tmpfiles, like volatiles without systemd.
- Run nginx with ${NGINX_USER} (user ${NGINX_USER} in nginx.conf)

Thanks, this was next on my TODO after collectd, excellent timing :)

And a thank you to Martin for fixing up the patch and redoing the intendation.

Quoted 48 lines
---
 meta-webserver/recipes-httpd/nginx/files/nginx.service | 9 ++++-----
 meta-webserver/recipes-httpd/nginx/nginx.inc           | 5 +++--
 2 files changed, 7 insertions(+), 7 deletions(-)
meta-webserver/recipes-httpd/nginx/files/nginx.service +4 -5
index 9926a4b..ce99061 100644
@@ -3,10 +3,9 @@ Description=Nginx Server
 After=network.target
 [Service]
 Type=forking
-PIDFile=@SYSCONFDIR@/nginx/run/nginx.pid
-ExecStartPre=@BASEBINDIR@/mkdir -p @LOCALSTATEDIR@/log/nginx
-ExecStart=@SYSCONFDIR@/init.d/nginx start
-ExecStop=@SYSCONFDIR@/init.d/nginx stop
+PIDFile=/run/nginx/nginx.pid
+ExecStart=@SBINDIR@/nginx
+ExecStop=@SBINDIR@/nginx -s stop
+ExecReload=@SBINDIR@/nginx -s reload
 [Install]
 WantedBy=multi-user.target
-
meta-webserver/recipes-httpd/nginx/nginx.inc +3 -2
index fe51ca0..334a6d8 100644
@@ -73,8 +73,8 @@ do_install () {
 	rm -fr ${D}${localstatedir}/run ${D}/run
 	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
 		install -d ${D}${sysconfdir}/tmpfiles.d
-		echo "d /run/${BPN} - - - -" \
-		     > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
+		echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
+			>> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
 	fi
 	install -d ${D}${sysconfdir}/${BPN}
 	ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
@@ -90,6 +90,7 @@ do_install () {
 	install -d ${D}${sysconfdir}/nginx
 	install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
 	sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
+	sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf
 	install -d ${D}${sysconfdir}/nginx/sites-enabled
 
 	install -d ${D}${sysconfdir}/default/volatiles
#5 lore raw
In reply to Martin Jansa

Hi,

Sorry for the wrong patch, but this has also some problems (inlined):

Quoted 41 lines · CEST Martin Jansa

From: Szombathelyi György <[email protected]>

- Call the nginx binary directly, no need to wrap the SysV init file.
- Create /var/log/nginx with tmpfiles, like volatiles without systemd.
- Run nginx with ${NGINX_USER} (user ${NGINX_USER} in nginx.conf)

---
 meta-webserver/recipes-httpd/nginx/files/nginx.service | 9 ++++-----
 meta-webserver/recipes-httpd/nginx/nginx.inc           | 5 +++--
 2 files changed, 7 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/meta-webserver/recipes-httpd/nginx/files/nginx.service index 9926a4b..ce99061 100644

meta-webserver/recipes-httpd/nginx/files/nginx.service +4 -5
@@ -3,10 +3,9 @@ Description=Nginx Server
 After=network.target
 [Service]
 Type=forking
-PIDFile=@SYSCONFDIR@/nginx/run/nginx.pid
-ExecStartPre=@BASEBINDIR@/mkdir -p @LOCALSTATEDIR@/log/nginx
-ExecStart=@SYSCONFDIR@/init.d/nginx start
-ExecStop=@SYSCONFDIR@/init.d/nginx stop
+PIDFile=/run/nginx/nginx.pid
+ExecStart=@SBINDIR@/nginx
+ExecStop=@SBINDIR@/nginx -s stop
+ExecReload=@SBINDIR@/nginx -s reload
 [Install]
 WantedBy=multi-user.target
-
(quoted diff) +0 -0

b/meta-webserver/recipes-httpd/nginx/nginx.inc index fe51ca0..334a6d8 100644

meta-webserver/recipes-httpd/nginx/nginx.inc +0 -0
@@ -73,8 +73,8 @@ do_install () {
 	rm -fr ${D}${localstatedir}/run ${D}/run
 	if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false',

d)}; then install -d ${D}${sysconfdir}/tmpfiles.d

meta-webserver/recipes-httpd/nginx/nginx.inc do_install () { · line 77

Quoted 2 lines
meta-webserver/recipes-httpd/nginx/nginx.inc +0 -2
-		echo "d /run/${BPN} - - - -" \
-		     > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf

Don't remove the /run/nginx directory, please

Quoted 13 lines
meta-webserver/recipes-httpd/nginx/nginx.inc +3 -0
+		echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
+			>> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
 	fi
 	install -d ${D}${sysconfdir}/${BPN}
 	ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
@@ -90,6 +90,7 @@ do_install () {
 	install -d ${D}${sysconfdir}/nginx
 	install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
 	sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
+	sed -i 's/^user.*/user ${NGINX_USER};/g'

${D}${sysconfdir}/nginx/nginx.conf install -d
${D}${sysconfdir}/nginx/sites-enabled

Quoted 1 line

install -d ${D}${sysconfdir}/default/volatiles

This is missing from the end, since the unit file refers to SBINDIR now, and no BASE_SBINDIR.

@@ -101,7 +104,7 @@ do_install () {
             install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/
system/
             sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
                     -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
-                    -e 's,@BASEBINDIR@,${base_bindir},g' \
+                    -e 's,@SBINDIR@,${sbindir},g' \
                     ${D}${systemd_unitdir}/system/nginx.service
         fi

}

#6 lore raw

Then please send tested v3.

Thanks

Quoted 85 lines · Szombathelyi György

Hi,

Sorry for the wrong patch, but this has also some problems (inlined):

Quoted 38 lines · CEST Martin Jansa

From: Szombathelyi György <[email protected]>

- Call the nginx binary directly, no need to wrap the SysV init file.
- Create /var/log/nginx with tmpfiles, like volatiles without systemd.
- Run nginx with ${NGINX_USER} (user ${NGINX_USER} in nginx.conf)

---
 meta-webserver/recipes-httpd/nginx/files/nginx.service | 9 ++++-----
 meta-webserver/recipes-httpd/nginx/nginx.inc           | 5 +++--
 2 files changed, 7 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/meta-webserver/recipes-httpd/nginx/files/nginx.service index 9926a4b..ce99061 100644

meta-webserver/recipes-httpd/nginx/files/nginx.service +4 -5
@@ -3,10 +3,9 @@ Description=Nginx Server
 After=network.target
 [Service]
 Type=forking
-PIDFile=@SYSCONFDIR@/nginx/run/nginx.pid
-ExecStartPre=@BASEBINDIR@/mkdir -p @LOCALSTATEDIR@/log/nginx
-ExecStart=@SYSCONFDIR@/init.d/nginx start
-ExecStop=@SYSCONFDIR@/init.d/nginx stop
+PIDFile=/run/nginx/nginx.pid
+ExecStart=@SBINDIR@/nginx
+ExecStop=@SBINDIR@/nginx -s stop
+ExecReload=@SBINDIR@/nginx -s reload
 [Install]
 WantedBy=multi-user.target
-
(quoted diff) +0 -0

b/meta-webserver/recipes-httpd/nginx/nginx.inc index fe51ca0..334a6d8 100644

meta-webserver/recipes-httpd/nginx/nginx.inc do_install () { · line 74

Quoted 2 lines
meta-webserver/recipes-httpd/nginx/nginx.inc +0 -0
@@ -73,8 +73,8 @@ do_install () {
      rm -fr ${D}${localstatedir}/run ${D}/run
      if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true',

'false',

meta-webserver/recipes-httpd/nginx/nginx.inc do_install () { · line 77

Quoted 3 lines

d)}; then install -d ${D}${sysconfdir}/tmpfiles.d

meta-webserver/recipes-httpd/nginx/nginx.inc +0 -2
-             echo "d /run/${BPN} - - - -" \
-                  > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf

Don't remove the /run/nginx directory, please

meta-webserver/recipes-httpd/nginx/nginx.inc do_install () { · line 91

Quoted 8 lines
meta-webserver/recipes-httpd/nginx/nginx.inc +2 -0
+             echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
+                     >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
      fi
      install -d ${D}${sysconfdir}/${BPN}
      ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
@@ -90,6 +90,7 @@ do_install () {
      install -d ${D}${sysconfdir}/nginx
      install -m 0644 ${WORKDIR}/nginx.conf

${D}${sysconfdir}/nginx/nginx.conf

meta-webserver/recipes-httpd/nginx/nginx.inc do_install () { · line 92

Quoted 1 line
meta-webserver/recipes-httpd/nginx/nginx.inc +0 -0
      sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.

conf

Quoted 5 lines
meta-webserver/recipes-httpd/nginx/nginx.inc +1 -0
+     sed -i 's/^user.*/user ${NGINX_USER};/g'

${D}${sysconfdir}/nginx/nginx.conf install -d
${D}${sysconfdir}/nginx/sites-enabled

      install -d ${D}${sysconfdir}/default/volatiles

This is missing from the end, since the unit file refers to SBINDIR now, and
no BASE_SBINDIR.

(quoted diff) +0 -0
@@ -101,7 +104,7 @@ do_install () {
             install -m 0644 ${WORKDIR}/nginx.service

${D}${systemd_unitdir}/
system/

             sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
                     -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
(quoted diff) +1 -1
-                    -e 's,@BASEBINDIR@,${base_bindir},g' \
+                    -e 's,@SBINDIR@,${sbindir},g' \
                     ${D}${systemd_unitdir}/system/nginx.service
         fi
 }
#7 lore raw
Quoted 2 lines · CEST Martin Jansa

Then please send tested v3.

Done. Hopefully OK this time.

Quoted 1 line

Thanks

Br,
György

Quoted 90 lines
Quoted 85 lines · Szombathelyi György

Hi,

Sorry for the wrong patch, but this has also some problems (inlined):

Quoted 38 lines · CEST Martin Jansa

From: Szombathelyi György <[email protected]>

- Call the nginx binary directly, no need to wrap the SysV init file.
- Create /var/log/nginx with tmpfiles, like volatiles without systemd.
- Run nginx with ${NGINX_USER} (user ${NGINX_USER} in nginx.conf)

---
 meta-webserver/recipes-httpd/nginx/files/nginx.service | 9 ++++-----
 meta-webserver/recipes-httpd/nginx/nginx.inc           | 5 +++--
 2 files changed, 7 insertions(+), 7 deletions(-)
(quoted diff) +0 -0

b/meta-webserver/recipes-httpd/nginx/files/nginx.service index 9926a4b..ce99061 100644

meta-webserver/recipes-httpd/nginx/files/nginx.service +4 -5
@@ -3,10 +3,9 @@ Description=Nginx Server
 After=network.target
 [Service]
 Type=forking
-PIDFile=@SYSCONFDIR@/nginx/run/nginx.pid
-ExecStartPre=@BASEBINDIR@/mkdir -p @LOCALSTATEDIR@/log/nginx
-ExecStart=@SYSCONFDIR@/init.d/nginx start
-ExecStop=@SYSCONFDIR@/init.d/nginx stop
+PIDFile=/run/nginx/nginx.pid
+ExecStart=@SBINDIR@/nginx
+ExecStop=@SBINDIR@/nginx -s stop
+ExecReload=@SBINDIR@/nginx -s reload
 [Install]
 WantedBy=multi-user.target
-
(quoted diff) +0 -0

b/meta-webserver/recipes-httpd/nginx/nginx.inc index fe51ca0..334a6d8 100644

meta-webserver/recipes-httpd/nginx/nginx.inc do_install () { · line 74

Quoted 2 lines
meta-webserver/recipes-httpd/nginx/nginx.inc +0 -0
@@ -73,8 +73,8 @@ do_install () {
      rm -fr ${D}${localstatedir}/run ${D}/run
      if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true',

'false',

meta-webserver/recipes-httpd/nginx/nginx.inc do_install () { · line 77

Quoted 3 lines

d)}; then install -d ${D}${sysconfdir}/tmpfiles.d

meta-webserver/recipes-httpd/nginx/nginx.inc +0 -2
-             echo "d /run/${BPN} - - - -" \
-                  > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf

Don't remove the /run/nginx directory, please

meta-webserver/recipes-httpd/nginx/nginx.inc do_install () { · line 91

Quoted 8 lines
meta-webserver/recipes-httpd/nginx/nginx.inc +2 -0
+             echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
+                     >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
      fi
      install -d ${D}${sysconfdir}/${BPN}
      ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
@@ -90,6 +90,7 @@ do_install () {
      install -d ${D}${sysconfdir}/nginx
      install -m 0644 ${WORKDIR}/nginx.conf

${D}${sysconfdir}/nginx/nginx.conf

meta-webserver/recipes-httpd/nginx/nginx.inc do_install () { · line 92

Quoted 1 line
meta-webserver/recipes-httpd/nginx/nginx.inc +0 -0
      sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.

conf

Quoted 5 lines
meta-webserver/recipes-httpd/nginx/nginx.inc +1 -0
+     sed -i 's/^user.*/user ${NGINX_USER};/g'

${D}${sysconfdir}/nginx/nginx.conf install -d
${D}${sysconfdir}/nginx/sites-enabled

      install -d ${D}${sysconfdir}/default/volatiles

This is missing from the end, since the unit file refers to SBINDIR now, and
no BASE_SBINDIR.

(quoted diff) +0 -0
@@ -101,7 +104,7 @@ do_install () {
             install -m 0644 ${WORKDIR}/nginx.service

${D}${systemd_unitdir}/
system/

             sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
                     -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
(quoted diff) +1 -1
-                    -e 's,@BASEBINDIR@,${base_bindir},g' \
+                    -e 's,@SBINDIR@,${sbindir},g' \
                     ${D}${systemd_unitdir}/system/nginx.service
         fi
 }