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

failed to start prototype "php_app", Failed to apply new configuration #1546

Open
ianchen07 opened this issue Jan 24, 2025 · 0 comments
Open

Comments

@ianchen07
Copy link

We are building our own unit-php image, based on php:8.3-zts-alpine3.20.

Docker file:

FROM public.ecr.aws/docker/library/php:8.3-zts-alpine3.20 AS base

ENV UNIT_VERSION=1.34.1

RUN apk update && apk add --no-cache
gcc
g++
make
linux-headers
libxml2-dev
pcre-dev
openssl-dev
zlib-dev
libstdc++
musl-dev
git
bash
openssh
build-base
autoconf
p7zip
gettext
&& curl -fsSL https://unit.nginx.org/download/unit-$UNIT_VERSION.tar.gz -o /tmp/unit.tar.gz
&& tar -xzf /tmp/unit.tar.gz -C /tmp/
&& cd /tmp/unit-$UNIT_VERSION
&& ./configure --prefix=/usr --statedir=/var/lib/unit --control=unix:/var/run/unit/control.unit.sock --runstatedir=/var/run --pid=/var/run/unit/unit.pid --logdir=/var/log --log=/dev/stdout --tmpdir=/var/tmp --modulesdir=/usr/lib/unit/modules
&& make
&& make install
&& ./configure php --module=php83 --config=/usr/local/bin/php-config --lib-path=/usr/local/lib/php
&& make php83
&& make install
&& rm -rf /tmp/unit*
&& apk del gcc g++ make musl-dev

RUN pecl install redis xdebug-3.3.1 uopz && echo "extension=uopz.so" > /usr/local/etc/php/conf.d/uopz.ini &&
docker-php-ext-install soap pdo_mysql opcache mysqli &&
docker-php-ext-enable redis xdebug soap pdo_mysql opcache mysqli

RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer --version=2.6.6

RUN mkdir -p /etc/unit
COPY ./docker/unit-config.json /etc/unit/config.json
COPY ./docker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

EXPOSE 80

RUN mkdir -p /var/symfony/cache
RUN mkdir -p /var/symfony/logs
RUN chmod -R 777 /var/symfony

COPY . /code/
WORKDIR /code

RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan bitbucket.org >> ~/.ssh/known_hosts
RUN --mount=type=ssh php -d memory_limit=-1 which composer install --prefer-dist --no-interaction

ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"]

Problem:
The unitd process can be initiated successfully by running inside container:
unitd --control unix:/var/run/unit/control.unit.sock
but when trying to update config:
curl -X PUT --unix-socket /var/run/unit/control.unit.sock --data-binary @/etc/unit/config.json http://localhost/config
I got error:
2025/01/24 02:43:17 [warn] 34#34 failed to start prototype "php_app"
2025/01/24 02:43:17 [alert] 34#34 failed to apply new conf
{
error": "Failed to apply new configuration."
}

The /etc/unit/config.json I have is:
{
"listeners": {
"*:80": {
"pass": "applications/php_app"
}
},
"applications": {
"php_app": {
"type": "php",
"root": "/code/public/"
}
}
}

Logs:
/code # /usr/local/bin/docker-entrypoint.sh
====== 1. Launching Unit daemon to perform initial configuration... ======
2025/01/24 02:43:17 [info] 19#19 unit 1.34.1 started
2025/01/24 02:43:17 [info] 27#27 discovery started
2025/01/24 02:43:17 [notice] 27#27 module: php 8.3.16 "/usr/lib/unit/modules/php83.unit.so"
2025/01/24 02:43:17 [info] 25#25 controller started
2025/01/24 02:43:17 [notice] 25#25 process 27 exited with code 0
2025/01/24 02:43:17 [info] 34#34 router started
2025/01/24 02:43:17 [info] 34#34 OpenSSL 3.3.2 3 Sep 2024, 30300020
{
"certificates": {},
"config": {
"listeners": {},
"routes": [],
"applications": {}
},

    "status": {
            "modules": {
                    "php": {
                            "version": "8.3.16",
                            "lib": "/usr/lib/unit/modules/php83.unit.so"
                    }
            },

            "connections": {
                    "accepted": 0,
                    "active": 0,
                    "idle": 0,
                    "closed": 0
            },

            "requests": {
                    "total": 0
            },

            "applications": {}
    }

}
====== 2. Waiting for Unit to be fully initialized... ======
Unit is ready.
====== 3. Applying configuration from /etc/unit/config.json... ======
2025/01/24 02:43:17 [alert] 25#25 process 53 exited on signal 11
2025/01/24 02:43:17 [warn] 34#34 failed to start prototype "php_app"
2025/01/24 02:43:17 [alert] 34#34 failed to apply new conf
/usr/local/bin/docker-entrypoint.sh: Error: HTTP response status code is '500'
}error": "Failed to apply new configuration."

I can't find any thread related to the failed to start prototype "php_app", does anyone have any idea or similar experience?

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

No branches or pull requests

1 participant