File: /volume1/@appstore/WebStation/misc/conf_webstation_php
#!/usr/bin/bash
CPU_MASK="0xfc0fc0"
function taskset_by_pidfile {
local pid_file=$1
local mask=$2
if [ -f "$pid_file" ]; then
local parent_pid
parent_pid=$(<"$pid_file")
/usr/bin/taskset -p "$mask" "$parent_pid" > /dev/null
for child_pid in $(/usr/bin/ps -o pid --ppid "$parent_pid" | /usr/bin/tail -n +2); do
/usr/bin/taskset -p "$mask" "$child_pid" > /dev/null
done
fi
}
php_list="$(/var/packages/WebStation/target/tools/synowebstation --get-php-profile-services)"
for php_service in $php_list; do
IFS='@' read -a php_array <<< "$php_service"
PHP_PID=${php_array[1]}
if [ -n "$PHP_PID" ]; then
taskset_by_pidfile "/run/php-fpm/php-$PHP_PID.pid" "$CPU_MASK"
fi
done