Skip to content

Commit

Permalink
Cleanup/Improve Platform.sh config for 1.13 (and up) (#234)
Browse files Browse the repository at this point in the history
* Update platform.sh config to place cache outside disk & add more inline doc

* Load cache tweaks only if redis and APCu is detected to be more errorprone

* Add missing loading of memcached config to be consitent with redis

* CS

* For now remove cache tweaks for symfony as it might not be cleared on ca:cl

* Remove solr config (will be handled seperatly) and other small cleanups

* Fixed bug: Basedir of dfs_nfs_path was set incorrectly on Platform.sh in some cases

* config comment out

* Remove some inline notes which is not needed for now

* Add deprecation for memcached and change comment on cache setting to avoid implying it will work out of the box

* Add rm to clear compiled classes, container and such before running console
  • Loading branch information
andrerom committed Feb 15, 2018
1 parent 1028558 commit f107019
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
40 changes: 27 additions & 13 deletions .platform.app.yaml
Expand Up @@ -26,6 +26,18 @@ relationships:
# this relationship and the corresponding service in .platform/services.yaml
#redissession: 'redissession:redis'

variables:
#php:
# Example of setting php.ini config
#"display_errors": "On"
env:
# For enterprise cluster, disable Symfony Proxy & instead use Fastly Bundle available on eZ Platform Enterprise
#SYMFONY_HTTP_CACHE: 0
# Change this to dev if you want to run site & commands in dev
SYMFONY_ENV: prod
# Uncomment if you want to use DFS clustering:
#PLATFORMSH_DFS_NFS_PATH: 'dfsdata'

# The configuration of app when it is exposed to the web.
web:
locations:
Expand All @@ -50,45 +62,47 @@ mounts:

# The hooks that will be performed when the package is deployed.
hooks:
# Build hook, done once before connected to services, disk is still writable here
build: |
set -e
rm web/app_dev.php
. ./.env
if [ -z "$SYMFONY_ENV" ]; then
export SYMFONY_ENV=prod
fi
if [ "$SYMFONY_ENV" = "dev" ] ; then
composer install --prefer-dist --no-progress --no-interaction --optimize-autoloader
else
composer install --no-dev --prefer-dist --no-progress --no-interaction --optimize-autoloader
fi
# Deploy hook, access to services & done on each server (if cluster), only mounts are writable at this point
deploy: |
set -e
. ./.env
if [ -z "$SYMFONY_ENV" ]; then
export SYMFONY_ENV=prod
fi
if [ ! -f web/var/.platform.installed ]; then
php -d memory_limit=-1 app/console ezplatform:install --env=$SYMFONY_ENV $INSTALL_EZ_INSTALL_TYPE
php -d memory_limit=-1 app/console ezplatform:install $INSTALL_EZ_INSTALL_TYPE
touch web/var/.platform.installed
fi
app/console --env=$SYMFONY_ENV cache:clear
# As we are deploying code changes we need to clear any kind of code/system cache
rm -f app/cache/*/*
app/console cache:clear
# Example of addtional deploy hooks if you use doctrine and/or kaliop migration bundle
##app/console doctrine:migrations:migrate --no-interaction --allow-no-migration
##app/console kaliop:migration:migrate --no-interaction --no-debug
# The configuration of scheduled execution.
# see http://symfony.com/doc/current/components/console/introduction.html
#crons:
# symfony:
# spec: "*/20 * * * *"
# cmd: "php cron.php example:test"
# cmd: "php app/console ezpublish:cron:run"

runtime:
extensions:
- xsl
- imagick
- readline
- redis
#- apcu
#- name: 'blackfire'
# configuration:
# server_id: 'xxxx-xxx-xxx-xxx-xxxx'
# server_token: 'xxxx'

# Uncomment if you want to use DFS clustering:
#variables:
#env:
#PLATFORMSH_DFS_NFS_PATH: 'dfsdata'
2 changes: 1 addition & 1 deletion .platform/services.yaml
@@ -1,5 +1,5 @@
mysqldb:
type: mysql:10.0
type: mysql:10.1
disk: 2048
configuration:
schemas:
Expand Down
14 changes: 12 additions & 2 deletions app/config/config_prod.yml
Expand Up @@ -2,15 +2,25 @@ imports:
- { resource: config.yml }
- { resource: ezplatform_prod.yml }

# Example below would make sure some of the symfony caches are written to apc / redis instead of disk
# Make sure to verify if cache clearing is done as you expect when doing such changes.

#framework:
# validation:
# cache: apc
# cache: validator.mapping.cache.doctrine.apc
# serializer:
# cache: serializer.mapping.cache.apc

#doctrine:
# orm:
# metadata_cache_driver: apc
# result_cache_driver: apc
# query_cache_driver: apc
## Result (& the experimental Second level) cache needs to be shared among servers so should use for instance Redis
# result_cache_driver:
# type: redis
# host:
# port:


monolog:
handlers:
Expand Down
7 changes: 6 additions & 1 deletion app/config/env/platformsh.php
Expand Up @@ -30,7 +30,7 @@
// PLATFORMSH_DFS_NFS_PATH is different compared to DFS_NFS_PATH in the sense that it is relative to ezplatform dir
// DFS_NFS_PATH is an absolute path
if ($dfsNfsPath = getenv('PLATFORMSH_DFS_NFS_PATH')) {
$container->setParameter('dfs_nfs_path', sprintf('%s/%s', getcwd(), $dfsNfsPath));
$container->setParameter('dfs_nfs_path', sprintf('%s/%s', dirname($container->getParameter('kernel.root_dir')), $dfsNfsPath));

if (array_key_exists('dfs_database', $relationships)) {
foreach ($relationships['dfs_database'] as $endpoint) {
Expand Down Expand Up @@ -79,8 +79,13 @@
continue;
}

@trigger_error('Usage of Memcached is deprecated, redis is recommended', E_USER_DEPRECATED);

$container->setParameter('cache_host', $endpoint['host']);
$container->setParameter('cache_memcached_port', $endpoint['port']);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../cache_pool'));
$loader->load('singlememcached.yml');
}
}

Expand Down

0 comments on commit f107019

Please sign in to comment.