Skip to content

[BUGFIX] Restart Apache on Alpine with supervisorctl and after an unclean exit - #631

Merged
Kanti merged 1 commit into
webdevops:masterfrom
andersundsehr:bugfix/apache-alpine-restart
Nov 17, 2026
Merged

Kanti merged 1 commit into
webdevops:masterfrom
andersundsehr:bugfix/apache-alpine-restart

Conversation

@Kanti

@Kanti Kanti commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

On Alpine, the start script of Apache runs httpd through apachectl, a shell script that does not exec it. supervisorctl stop and restart end apachectl, but httpd keeps running with its old configuration, and the new start exits with httpd (pid N) already running, over and over. The script also removes /var/run/httpd/httpd.pid, while Apache on Alpine writes /run/apache2/httpd.pid, so after an unclean exit a pid file that names a running process keeps Apache from starting.

The script now removes /run/apache2/httpd.pid and runs exec /usr/sbin/httpd -DFOREGROUND. Debian already execs apache2.

Related: #457 (wrong pid path in the Alpine images, boot loop after an unclean exit), closed, but it still applies to the published images; #458 (pull request with the pid path, against files that are no longer generated, without the apachectl part).

Changes

  • provisioning/apache/alpine/bin/service.d/httpd.sh, provisioning/php-apache/alpine/bin/service.d/httpd.sh: the pid file of Alpine, and exec httpd instead of apachectl; make generate.
  • Image test testSupervisorctlRestartsApache in ApacheChecks: adds a configuration with a header, stops Apache, writes a pid file that names supervisord, starts Apache, and checks the header and that Apache keeps its process for 6 s.

How it was verified

The published php-apache:8.5-alpine, with and without the new httpd.sh mounted over /opt/docker/bin/service.d/httpd.sh: a configuration with a header added, supervisorctl stop apache:apached, echo 1 > /run/apache2/httpd.pid, supervisorctl start apache:apached:

Published image With the new httpd.sh
Header of the new configuration missing, the old httpd still answers X-Image-Test-Restart: restarted
supervisorctl pid apache:apached 212, 6 s later 238, then 243: restarted over and over 183, 6 s later still 183

Image tests from the fork, with the new httpd.sh copied into the published images:

Image Published image With the fix
apache:alpine 1 failure: the header is missing, the old httpd still answers all tests pass
php-apache:8.5-alpine 1 failure, the same all tests pass
php-apache:8.5 (Debian) passes not changed

Rebased on master with #630; ci/console generate changes nothing. The CI run of this pull request runs the new test in the Apache images, Debian and Alpine, amd64 and arm64.

Nginx images

Nginx is not affected. Its start script already runs exec /usr/sbin/nginx -g 'daemon off;', on Debian and Alpine. Checked on the published php-nginx:8.5-alpine: after supervisorctl restart nginx:nginxd the program is RUNNING, there is one Nginx master process, Nginx answers, and the log has no already running. This pull request does not change Nginx.

…lean exit

On Alpine, the start script ran httpd through apachectl, a shell script
that does not exec it. supervisorctl stop and restart ended apachectl,
but httpd kept running with its old configuration, and the new one exited
with "httpd (pid N) already running", over and over. The script also
removed /var/run/httpd/httpd.pid, while Apache on Alpine writes
/run/apache2/httpd.pid, so after an unclean exit a pid file that names a
running process kept Apache from starting.

The script now removes /run/apache2/httpd.pid and execs httpd itself.
The image tests restart Apache with a new configuration and a pid file
that names a running process, and check the configuration and that Apache
keeps running.
@sonarqubecloud

Copy link
Copy Markdown

@Kanti
Kanti marked this pull request as ready for review November 17, 2026 12:50
@Kanti
Kanti merged commit 485f0bb into webdevops:master Nov 17, 2026
357 of 358 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant