Skip to content

nginx start can't get cpu limit and change worker_processes numbers #472

@Darren-wh

Description

@Darren-wh

nginx start can't get cpu limit and change worker_processes numbers.
I think you can add follow scripts to docker-entrypoint.sh.

CPU_CFS_QUOTA_US=`cat /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us`
CPU_CFS_PERIOD_US=`cat /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us`
if [ "$CPU_CFS_PERIOD_US" -ne "-1" ]
then
WORKER_PROCESSES=`awk 'BEGIN{printf "%.2f\n",'''$CPU_CFS_QUOTA_US'''/'''$CPU_CFS_PERIOD_US'''}'|awk '{print int($1+1)}'`
sed  -i "s/worker_processes  2/worker_processes  $WORKER_PROCESSES/g" /etc/nginx/nginx.conf
fi

add this script,The nginx can start with the worker_processes auto.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions