Select and persist a PHP-FPM series for each website
This commit is contained in:
1 parent
b249cf06a9
commit
0c8a28b7e2
26 files changed
+1344
-164
No files matched your search
@@ -37,6 +37,7 @@ from coulobre.php_pool_settings import (
|
||||
PhpPoolSettings,
|
||||
PhpPoolSettingsError,
|
||||
)
|
||||
from coulobre.php_runtime import validate_php_versions
|
||||
from coulobre.web_node import MAX_STORAGE_LIMIT_MIB
|
||||
|
||||
from .fields import DomainNameField
|
||||
@@ -294,6 +295,15 @@ class HostingPlan(models.Model):
|
||||
php_max_children = php_plan_field(
|
||||
"max_children", "Maximum PHP-FPM workers"
|
||||
)
|
||||
php_versions = models.CharField(
|
||||
"Allowed PHP series",
|
||||
max_length=120,
|
||||
blank=True,
|
||||
help_text=(
|
||||
"Comma-separated series such as 8.4, 8.5. "
|
||||
"Leave blank for all installed stable series."
|
||||
),
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ("name", "pk")
|
||||
@@ -303,6 +313,10 @@ class HostingPlan(models.Model):
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
try:
|
||||
validate_php_versions(self.allowed_php_versions())
|
||||
except ValueError as error:
|
||||
raise ValidationError({"php_versions": str(error)}) from error
|
||||
try:
|
||||
self.get_php_settings()
|
||||
except PhpPoolSettingsError as error:
|
||||
@@ -318,6 +332,13 @@ class HostingPlan(models.Model):
|
||||
}
|
||||
)
|
||||
|
||||
def allowed_php_versions(self):
|
||||
if not self.php_versions:
|
||||
return ()
|
||||
return tuple(
|
||||
version.strip() for version in self.php_versions.split(",")
|
||||
)
|
||||
|
||||
|
||||
class HostingAccount(models.Model):
|
||||
name = models.CharField(max_length=120)
|
||||
@@ -762,6 +783,18 @@ class WebActivation(ProvisioningJob):
|
||||
)
|
||||
|
||||
php_settings = models.JSONField(null=True, blank=True)
|
||||
applied_php_version = models.CharField(max_length=5, blank=True)
|
||||
|
||||
|
||||
class SitePhpVersion(ProvisioningJob):
|
||||
account = models.OneToOneField(
|
||||
HostingAccount,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="php_version_job",
|
||||
)
|
||||
domain = DomainNameField(max_length=253)
|
||||
requested_version = models.CharField(max_length=5)
|
||||
applied_version = models.CharField(max_length=5, blank=True)
|
||||
|
||||
|
||||
class SitePhpSettings(ProvisioningJob):
|
||||
|
||||
Reference in new issue
Block a user