Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature for creating site with proxy-cache #72

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,22 @@ public function __construct() {
* : Path to the SSL crt file.
*
* [--wildcard]
* : Gets wildcard SSL .
* : Gets wildcard SSL.
*
* [--proxy-cache=<on-or-off>]
* : Enable or disable proxy cache on site.
* ---
* default: off
* options:
* - on
* - off
* ---
*
* [--proxy-cache-max-size=<size-in-m-or-g>]
* : Max size for proxy-cache.
*
* [--proxy-cache-max-time=<time-in-s-or-m>]
* : Max time for proxy cache to last.
*
* [--force]
* : Resets the remote database if it is not empty.
Expand Down Expand Up @@ -183,10 +198,14 @@ public function create( $args, $assoc_args ) {
$this->site_data['site_ssl_wildcard'] = \EE\Utils\get_flag_value( $assoc_args, 'wildcard' );
$this->site_data['php_version'] = \EE\Utils\get_flag_value( $assoc_args, 'php', 'latest' );
$this->site_data['app_sub_type'] = 'php';
$this->site_data['proxy-cache'] = \EE\Utils\get_flag_value( $assoc_args, 'proxy-cache' );

$this->site_data['site_container_fs_path'] = get_public_dir( $assoc_args );

$local_cache = \EE\Utils\get_flag_value( $assoc_args, 'with-local-redis' );
if ( 'on' === $this->site_data['proxy-cache'] ) {
$this->cache_type = true;
}
$this->site_data['cache_host'] = '';

if ( $this->cache_type ) {
Expand Down Expand Up @@ -767,6 +786,10 @@ private function create_site( $assoc_args ) {
}

$this->www_ssl_wrapper( [ 'nginx' ] );

if ( 'on' === $this->site_data['proxy-cache'] ) {
$this->update_proxy_cache( [], $assoc_args, true );
}
} catch ( \Exception $e ) {
$this->catch_clean( $e );
}
Expand All @@ -789,6 +812,7 @@ private function create_site_db_entry() {
'cache_nginx_fullpage' => (int) $this->cache_type,
'cache_mysql_query' => (int) $this->cache_type,
'cache_host' => $this->site_data['cache_host'],
'proxy_cache' => $this->site_data['proxy-cache'],
'site_fs_path' => $this->site_data['site_fs_path'],
'site_ssl' => $this->site_data['site_ssl'],
'site_ssl_wildcard' => $this->site_data['site_ssl_wildcard'] ? 1 : 0,
Expand Down