Render php-fpm pool from template
This commit is contained in:
@@ -527,66 +527,26 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
"/etc/php/7.2/fpm/php.ini")
|
"/etc/php/7.2/fpm/php.ini")
|
||||||
config.write(configfile)
|
config.write(configfile)
|
||||||
|
|
||||||
# Parse /etc/php/7.2/fpm/php-fpm.conf
|
# Render php-fpm pool template for php7.3
|
||||||
data = dict(pid="/run/php/php7.2-fpm.pid",
|
data = dict(pid="/run/php/php7.2-fpm.pid",
|
||||||
error_log="/var/log/php/7.2/fpm.log",
|
error_log="/var/log/php7.2-fpm.log",
|
||||||
include="/etc/php/7.2/fpm/pool.d/*.conf")
|
include="/etc/php/7.2/fpm/pool.d/*.conf")
|
||||||
Log.debug(self, "writting php7.2 configuration into "
|
WOTemplate.deploy(
|
||||||
"/etc/php/7.2/fpm/php-fpm.conf")
|
self, '/etc/php/7.2/fpm/php-fpm.conf',
|
||||||
wo_php_fpm = open('/etc/php/7.2/fpm/php-fpm.conf',
|
'php-fpm.mustache', data)
|
||||||
encoding='utf-8', mode='w')
|
|
||||||
self.app.render((data), 'php-fpm.mustache', out=wo_php_fpm)
|
|
||||||
wo_php_fpm.close()
|
|
||||||
|
|
||||||
if not os.path.isfile('/etc/php/7.2/fpm/pool.d/www.conf.orig'):
|
data = dict(pool='www-php72', listen='php72-fpm.sock',
|
||||||
WOFileUtils.copyfile(self, '/etc/php/7.2/fpm/pool.d/www.conf',
|
user='www-data',
|
||||||
'/etc/php/7.2/fpm/pool.d/www.conf.orig')
|
group='www-data', listenuser='root',
|
||||||
# Parse /etc/php/7.2/fpm/pool.d/www.conf
|
listengroup='www-data', openbasedir=True)
|
||||||
config = configparser.ConfigParser()
|
WOTemplate.deploy(self, '/etc/php/7.2/fpm/pool.d/www.conf',
|
||||||
config.read_file(codecs.open('/etc/php/7.2/fpm/'
|
'php-pool.mustache', data)
|
||||||
'pool.d/www.conf.orig',
|
data = dict(pool='www-two-php72', listen='php72-two-fpm.sock',
|
||||||
"r", "utf8"))
|
user='www-data',
|
||||||
config['www']['ping.path'] = '/ping'
|
group='www-data', listenuser='root',
|
||||||
config['www']['pm.status_path'] = '/status'
|
listengroup='www-data', openbasedir=True)
|
||||||
config['www']['pm.max_requests'] = '1500'
|
WOTemplate.deploy(self, '/etc/php/7.2/fpm/pool.d/www-two.conf',
|
||||||
config['www']['pm.max_children'] = '50'
|
'php-pool.mustache', data)
|
||||||
config['www']['pm.start_servers'] = '10'
|
|
||||||
config['www']['pm.min_spare_servers'] = '5'
|
|
||||||
config['www']['pm.max_spare_servers'] = '15'
|
|
||||||
config['www']['request_terminate_timeout'] = '300'
|
|
||||||
config['www']['pm'] = 'ondemand'
|
|
||||||
config['www']['chdir'] = '/'
|
|
||||||
config['www']['prefix'] = '/var/run/php'
|
|
||||||
config['www']['listen'] = 'php72-fpm.sock'
|
|
||||||
config['www']['listen.mode'] = '0660'
|
|
||||||
config['www']['listen.backlog'] = '32768'
|
|
||||||
config['www']['catch_workers_output'] = 'yes'
|
|
||||||
with codecs.open('/etc/php/7.2/fpm/pool.d/www.conf',
|
|
||||||
encoding='utf-8', mode='w') as configfile:
|
|
||||||
Log.debug(self, "Writing PHP 7.2 configuration into "
|
|
||||||
"/etc/php/7.2/fpm/pool.d/www.conf")
|
|
||||||
config.write(configfile)
|
|
||||||
|
|
||||||
with open("/etc/php/7.2/fpm/pool.d/www.conf",
|
|
||||||
encoding='utf-8', mode='a') as myfile:
|
|
||||||
myfile.write("\nphp_admin_value[open_basedir] "
|
|
||||||
"= \"/var/www/:/usr/share/php/:"
|
|
||||||
"/tmp/:/var/run/nginx-cache/:"
|
|
||||||
"/dev/shm:/dev/urandom\"\n")
|
|
||||||
|
|
||||||
# Generate /etc/php/7.2/fpm/pool.d/www-two.conf
|
|
||||||
WOFileUtils.copyfile(self, "/etc/php/7.2/fpm/pool.d/www.conf",
|
|
||||||
"/etc/php/7.2/fpm/pool.d/www-two.conf")
|
|
||||||
WOFileUtils.searchreplace(self, "/etc/php/7.2/fpm/pool.d/"
|
|
||||||
"www-two.conf", "[www]", "[www-two]")
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
config.read('/etc/php/7.2/fpm/pool.d/www-two.conf')
|
|
||||||
config['www-two']['listen'] = 'php72-two-fpm.sock'
|
|
||||||
with open('/etc/php/7.2/fpm/pool.d/www-two.conf',
|
|
||||||
encoding='utf-8', mode='w') as confifile:
|
|
||||||
Log.debug(self, "writting PHP7.2 configuration into "
|
|
||||||
"/etc/php/7.2/fpm/pool.d/www-two.conf")
|
|
||||||
config.write(confifile)
|
|
||||||
|
|
||||||
# Generate /etc/php/7.2/fpm/pool.d/debug.conf
|
# Generate /etc/php/7.2/fpm/pool.d/debug.conf
|
||||||
WOFileUtils.copyfile(self, "/etc/php/7.2/fpm/pool.d/www.conf",
|
WOFileUtils.copyfile(self, "/etc/php/7.2/fpm/pool.d/www.conf",
|
||||||
@@ -700,66 +660,26 @@ def post_pref(self, apt_packages, packages, upgrade=False):
|
|||||||
"/etc/php/7.3/fpm/php.ini")
|
"/etc/php/7.3/fpm/php.ini")
|
||||||
config.write(configfile)
|
config.write(configfile)
|
||||||
|
|
||||||
# Parse /etc/php/7.3/fpm/php-fpm.conf
|
# Render php-fpm pool template for php7.3
|
||||||
data = dict(pid="/run/php/php7.3-fpm.pid",
|
data = dict(pid="/run/php/php7.3-fpm.pid",
|
||||||
error_log="/var/log/php7.3-fpm.log",
|
error_log="/var/log/php7.3-fpm.log",
|
||||||
include="/etc/php/7.3/fpm/pool.d/*.conf")
|
include="/etc/php/7.3/fpm/pool.d/*.conf")
|
||||||
Log.debug(self, "writting php 7.3 configuration into "
|
WOTemplate.deploy(
|
||||||
"/etc/php/7.3/fpm/php-fpm.conf")
|
self, '/etc/php/7.3/fpm/php-fpm.conf',
|
||||||
wo_php_fpm = open('/etc/php/7.3/fpm/php-fpm.conf',
|
'php-fpm.mustache', data)
|
||||||
encoding='utf-8', mode='w')
|
|
||||||
self.app.render((data), 'php-fpm.mustache', out=wo_php_fpm)
|
|
||||||
wo_php_fpm.close()
|
|
||||||
|
|
||||||
# Parse /etc/php/7.3/fpm/pool.d/www.conf
|
data = dict(pool='www-php73', listen='php73-fpm.sock',
|
||||||
if not os.path.isfile('/etc/php/7.3/fpm/pool.d/www.conf.orig'):
|
user='www-data',
|
||||||
WOFileUtils.copyfile(self, '/etc/php/7.3/fpm/pool.d/www.conf',
|
group='www-data', listenuser='root',
|
||||||
'/etc/php/7.3/fpm/pool.d/www.conf.orig')
|
listengroup='www-data', openbasedir=True)
|
||||||
config = configparser.ConfigParser()
|
WOTemplate.deploy(self, '/etc/php/7.3/fpm/pool.d/www.conf',
|
||||||
config.read_file(codecs.open('/etc/php/7.3/fpm/'
|
'php-pool.mustache', data)
|
||||||
'pool.d/www.conf.orig',
|
data = dict(pool='www-two-php73', listen='php73-two-fpm.sock',
|
||||||
"r", "utf8"))
|
user='www-data',
|
||||||
config['www']['ping.path'] = '/ping'
|
group='www-data', listenuser='root',
|
||||||
config['www']['pm.status_path'] = '/status'
|
listengroup='www-data', openbasedir=True)
|
||||||
config['www']['pm.max_requests'] = '1500'
|
WOTemplate.deploy(self, '/etc/php/7.3/fpm/pool.d/www-two.conf',
|
||||||
config['www']['pm.max_children'] = '50'
|
'php-pool.mustache', data)
|
||||||
config['www']['pm.start_servers'] = '10'
|
|
||||||
config['www']['pm.min_spare_servers'] = '5'
|
|
||||||
config['www']['pm.max_spare_servers'] = '15'
|
|
||||||
config['www']['request_terminate_timeout'] = '300'
|
|
||||||
config['www']['pm'] = 'ondemand'
|
|
||||||
config['www']['chdir'] = '/'
|
|
||||||
config['www']['prefix'] = '/var/run/php'
|
|
||||||
config['www']['listen'] = 'php73-fpm.sock'
|
|
||||||
config['www']['listen.mode'] = '0660'
|
|
||||||
config['www']['listen.backlog'] = '32768'
|
|
||||||
config['www']['catch_workers_output'] = 'yes'
|
|
||||||
with codecs.open('/etc/php/7.3/fpm/pool.d/www.conf',
|
|
||||||
encoding='utf-8', mode='w') as configfile:
|
|
||||||
Log.debug(self, "writting PHP 7.3 configuration into "
|
|
||||||
"/etc/php/7.3/fpm/pool.d/www.conf")
|
|
||||||
config.write(configfile)
|
|
||||||
|
|
||||||
with open("/etc/php/7.3/fpm/pool.d/www.conf",
|
|
||||||
encoding='utf-8', mode='a') as myfile:
|
|
||||||
myfile.write("\nphp_admin_value[open_basedir] "
|
|
||||||
"= \"/var/www/:/usr/share/php/:"
|
|
||||||
"/tmp/:/var/run/nginx-cache/:"
|
|
||||||
"/dev/shm:/dev/urandom\"\n")
|
|
||||||
|
|
||||||
# Generate /etc/php/7.3/fpm/pool.d/www-two.conf
|
|
||||||
WOFileUtils.copyfile(self, "/etc/php/7.3/fpm/pool.d/www.conf",
|
|
||||||
"/etc/php/7.3/fpm/pool.d/www-two.conf")
|
|
||||||
WOFileUtils.searchreplace(self, "/etc/php/7.3/fpm/pool.d/"
|
|
||||||
"www-two.conf", "[www]", "[www-two]")
|
|
||||||
config = configparser.ConfigParser()
|
|
||||||
config.read('/etc/php/7.3/fpm/pool.d/www-two.conf')
|
|
||||||
config['www-two']['listen'] = 'php73-two-fpm.sock'
|
|
||||||
with open('/etc/php/7.3/fpm/pool.d/www-two.conf',
|
|
||||||
encoding='utf-8', mode='w') as confifile:
|
|
||||||
Log.debug(self, "writting PHP7.3 configuration into "
|
|
||||||
"/etc/php/7.3/fpm/pool.d/www-two.conf")
|
|
||||||
config.write(confifile)
|
|
||||||
|
|
||||||
# Generate /etc/php/7.3/fpm/pool.d/debug.conf
|
# Generate /etc/php/7.3/fpm/pool.d/debug.conf
|
||||||
WOFileUtils.copyfile(self, "/etc/php/7.3/fpm/pool.d/www.conf",
|
WOFileUtils.copyfile(self, "/etc/php/7.3/fpm/pool.d/www.conf",
|
||||||
|
|||||||
23
wo/cli/templates/php-pool.mustache
Normal file
23
wo/cli/templates/php-pool.mustache
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
[{{pool}}]
|
||||||
|
user = {{user}}
|
||||||
|
group = {{group}}
|
||||||
|
listen = {{listen}}
|
||||||
|
listen.owner = {{listenuser}}
|
||||||
|
listen.group = {{listengroup}}
|
||||||
|
pm = ondemand
|
||||||
|
pm.max_children = 50
|
||||||
|
pm.start_servers = 10
|
||||||
|
pm.min_spare_servers = 5
|
||||||
|
pm.max_spare_servers = 15
|
||||||
|
ping.path = /ping
|
||||||
|
pm.status_path = /status
|
||||||
|
pm.max_requests = 1500
|
||||||
|
request_terminate_timeout = 300
|
||||||
|
chdir = /
|
||||||
|
prefix = /var/run/php
|
||||||
|
listen.mode = 0660
|
||||||
|
listen.backlog = 32768
|
||||||
|
catch_workers_output = yes
|
||||||
|
|
||||||
|
|
||||||
|
{{#openbasedir}}php_admin_value[open_basedir] = "/var/www/:/usr/share/php/:/tmp/:/var/run/nginx-cache/"{{/openbasedir}}
|
||||||
Reference in New Issue
Block a user