Skip to content

Commit

Permalink
libre
Browse files Browse the repository at this point in the history
  • Loading branch information
craigcomstock committed Sep 12, 2024
1 parent 41ac752 commit 28024df
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cfe_internal/enterprise/mission_portal.cf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ bundle agent cfe_internal_enterprise_mission_portal
handle => "cfe_internal_management_web_server",
comment => "Manage Apache Web server (on/off)";

"PHP FastCGI process manager"
usebundle => service_config(
"cf-php-fpm",
"$(this.promise_dirname)/templates/php-fpm.conf.mustache",
"$(sys.workdir)/httpd/php/etc/php-fpm.conf",
"$(sys.workdir)/httpd/php/sbin/php-fpm -t --fpm-config ");

"PHP FastCGI www pool config"
usebundle => service_config(
"cf-php-fpm",
"$(this.promise_dirname)/templates/php-fpm-pool-www.conf.mustache",
"$(sys.workdir)/httpd/php/etc/php-fpm.d/www.conf",
"$(sys.workdir)/httpd/php/sbin/php-fpm -t --fpm-config ");

}
bundle agent apachectl_patched_for_upgrade
# @brief Ensure that apacehctl is patched so that it is able to re-start services
Expand Down
51 changes: 51 additions & 0 deletions lib/service_config.cf
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# todo, maybe chmod, user, group for config_final_path
# check pid file for service stop/start?
bundle agent service_config(service_name,
config_template_path,
config_final_path,
validate_config_command)
{
vars:
"staged_config" string => "$(config_final_path).staged";
"data" data => datastate();
methods:
"staged config rendered" usebundle => file_make_mustache( $(staged_config), $(config_template_path), @(data) );
"final config and restart" usebundle => validate_config_and_restart_service(
$(staged_config),
$(validate_config_command),
$(config_final_path),
$(service_name)
);


}
bundle agent validate_config_and_restart_service( staged_config, validate_config_command, config_final_path, service_name )
{
files:
"$(config_final_path)"
copy_from => local_dcp( $(staged_config) ),
if => and(
isnewerthan( $(config_final_path), $(staged_config) ),
returnszero("$(validate_config_command) $(staged_config)", "useshell")
),
classes => results("bundle", "$(service_name)_config");

services:
"$(service_name)"
service_policy => "stop",
if => and(
isnewerthan( $(config_final_path), $(staged_config) ),
returnszero("$(validate_config_command) $(staged_config)", "useshell")
),
classes => results("bundle", "$(service_name)_stopped_after_validated_config");

"$(service_name)"
service_policy => "start",
if => and( "$(service_name)_config_repaired",
"$(service_name)_stopped_after_validated_config_repaired");

"$(service_name)"
service_policy => "restart",
if => and( "$(service_name)_config_repaired",
not( "$(service_name)_stoppoed_after_validated_config_repaired") );
}
6 changes: 6 additions & 0 deletions templates/cf-apache.service.mustache
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
[Unit]
Description=CFEngine Enterprise Webserver
After=syslog.target
{{#classes.mission_portal_http2_enabled}}
Wants=cf-php-fpm.service
After=cf-php-fpm.service
{{/classes.mission_portal_http2_enabled}}
{{^classes.mission_portal_http2_enabled}}
Wants=cf-postgres.service
After=cf-postgres.service
{{/classes.mission_portal_http2_enabled}}
ConditionPathExists={{{vars.sys.workdir}}}/httpd/bin/apachectl
PartOf=cfengine3.service

Expand Down

0 comments on commit 28024df

Please sign in to comment.