Added support for multiple webservers

This commit is contained in:
Marc Aymerich 2017-07-05 13:55:13 +00:00
parent 0c1b4c7f4a
commit a1f73d883a
5 changed files with 10 additions and 3 deletions

View file

@ -23,6 +23,8 @@ class WebApp(models.Model):
related_name='webapps')
data = JSONField(_("data"), blank=True, default={},
help_text=_("Extra information dependent of each service."))
target_server = models.ForeignKey('orchestration.Server', verbose_name=_("Target Server"),
related_name='webapps')
# CMS webapps usually need a database and dbuser, with these virtual fields we tell the ORM to delete them
databases = VirtualDatabaseRelation('databases.Database')

View file

@ -99,6 +99,7 @@ WEBAPPS_PHP_VERSIONS = Setting('WEBAPPS_PHP_VERSIONS', (
('5.3-cgi', 'PHP 5.3 FCGID'),
('5.2-cgi', 'PHP 5.2 FCGID'),
('4-cgi', 'PHP 4 FCGID'),
('7-fpm', 'PHP 7 FPM')
),
help_text="Execution modle choose by ending -fpm or -cgi.",
validators=[Setting.validate_choices]

View file

@ -69,7 +69,7 @@ class WebsiteAdmin(SelectAccountAdminMixin, ExtendedModelAdmin):
fieldsets = (
(None, {
'classes': ('extrapretty',),
'fields': ('account_link', 'name', 'protocol', 'domains', 'is_active'),
'fields': ('account_link', 'name', 'protocol', 'target_server', 'domains', 'is_active'),
}),
)
form = WebsiteAdminForm

View file

@ -58,7 +58,8 @@ class Apache2Controller(ServiceController):
context.update({
'port': self.HTTPS_PORT if ssl else self.HTTP_PORT,
'vhost_set_fcgid': False,
'server_alias_lines': ' \\\n '.join(context['server_alias'])
'server_alias_lines': ' \\\n '.join(context['server_alias']),
'suexec_needed': site.target_server == 'web.pangea.lan'
})
context['extra_conf'] = self.get_extra_conf(site, context, ssl)
return Template(textwrap.dedent("""\
@ -71,7 +72,8 @@ class Apache2Controller(ServiceController):
CustomLog {{ access_log }} common{% endif %}\
{% if error_log %}
ErrorLog {{ error_log }}{% endif %}
SuexecUserGroup {{ user }} {{ group }}\
{% if suexec_needed %}
SuexecUserGroup {{ user }} {{ group }}{% endif %}\
{% for line in extra_conf.splitlines %}
{{ line | safe }}{% endfor %}
</VirtualHost>

View file

@ -34,6 +34,8 @@ class Website(models.Model):
domains = models.ManyToManyField(settings.WEBSITES_DOMAIN_MODEL, blank=True,
related_name='websites', verbose_name=_("domains"))
contents = models.ManyToManyField('webapps.WebApp', through='websites.Content')
target_server = models.ForeignKey('orchestration.Server', verbose_name=_("Target Server"),
related_name='websites')
is_active = models.BooleanField(_("active"), default=True)
class Meta: