Skip to content

Commit e7e8da7

Browse files
Merge pull request #399 from symfony-cmf/an_other_try
An other try
2 parents ec20a57 + 0a4a74c commit e7e8da7

File tree

3 files changed

+55
-37
lines changed

3 files changed

+55
-37
lines changed

.platform.app.yaml

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,7 @@ web:
4545
cron:
4646
symfony:
4747
spec: '* */2 * * *'
48-
cmd: |
49-
# force clearing the cache
50-
rm -rf var/cache/prod
51-
bin/console --env=prod doctrine:phpcr:init:dbal --drop --force
52-
bin/console --env=prod doctrine:phpcr:repository:init
53-
bin/console --env=prod doctrine:phpcr:fixtures:load -n
54-
bin/console --env=prod cache:warmup -n --no-debug
48+
cmd: ./bin/reloadFixtures.sh $PWD
5549

5650
# The size of the persistent disk of the application (in MB).
5751
disk: 2048
@@ -64,18 +58,16 @@ mounts:
6458
# The hooks that will be performed when the package is deployed.
6559
hooks:
6660
build: |
67-
rm web/app_dev.php
61+
if [ "$PLATFORM_BRANCH" = master ]; then
62+
rm web/app_dev.php
63+
else
64+
echo "only remove app_dev.php on master"
65+
fi
6866
# place sqlite file into /tmp so that we can write to it during deploy
6967
sed -i 's@%kernel.root_dir%/../var/app.sqlite@/tmp/app.sqlite@' app/config/parameters.yml
7068
bin/console --env=prod assets:install -n --no-debug
7169
bin/console --env=prod assetic:dump -n --no-debug
72-
deploy: |
73-
# force clearing the cache
74-
rm -rf var/cache/prod
75-
bin/console --env=prod doctrine:phpcr:init:dbal --drop --force -n
76-
bin/console --env=prod doctrine:phpcr:repository:init -n
77-
bin/console --env=prod doctrine:phpcr:fixtures:load -n
78-
bin/console --env=prod cache:warmup -n --no-debug
70+
deploy: ./bin/reloadFixtures.sh $PWD
7971

8072
runtime:
8173
extensions:

bin/reloadFixtures.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
DIR=$1
4+
run () {
5+
comment="+++ "$1" +++"
6+
command=$2
7+
echo ${comment}
8+
echo "Command: "${command}
9+
${command}
10+
OUT=$?
11+
if [ ${OUT} -eq 0 ];then
12+
echo "+++ DONE +++"
13+
echo
14+
else
15+
echo "+++ Errors +++"
16+
exit ${OUT}
17+
fi
18+
}
19+
20+
CACHE_DIR=${DIR}var/cache/prod
21+
#run "Remove cache directory:" "rm -rf ${CACHE_DIR}"
22+
run "Drop and init dbal:" "php ${DIR}bin/console --env=prod doctrine:phpcr:init:dbal --drop --force -n"
23+
run "Init repositories:" "php ${DIR}bin/console --env=prod doctrine:phpcr:repository:init -n"
24+
run "Load date fixtures:" "php ${DIR}bin/console --env=prod doctrine:phpcr:fixtures:load -n"
25+
run "Warm up cache:" "php ${DIR}bin/console --env=prod cache:warmup -n --no-debug"

web/reload-fixtures.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
<pre>
21
<?php
32

4-
function runCommand($command, $shouldHaveOutput = true)
3+
function outputNice($output)
54
{
6-
$output = $return_var = null;
7-
echo "Running: $command\n";
8-
exec($command, $output, $return_var);
9-
10-
if (!$shouldHaveOutput) {
11-
return;
5+
if (is_array($output)) {
6+
foreach ($output as $line) {
7+
printf("<pre><code>%s</code>", $line);
8+
}
9+
} else {
10+
printf("<pre><code>%s</code>", $output);
1211
}
12+
}
1313

14-
if (empty($output) || !is_array($output)) {
15-
echo 'Fixtures could not be loaded: '.var_export($return_var, true);
16-
exit(1);
17-
}
18-
echo PHP_EOL;
19-
echo "Output:\n";
20-
foreach ($output as $line) {
21-
echo $line."\n";
22-
}
14+
$commandFile = __DIR__.'/../bin/reloadFixtures.sh';
15+
if (!file_exists($commandFile)) {
16+
outputNice('File not found at: '.$commandFile);
2317
}
2418

25-
runCommand('rm -rf var/cache/prod', false);
26-
runCommand(__DIR__.'/../bin/console --env=prod doctrine:phpcr:init:dbal --drop --force');
27-
runCommand(__DIR__.'/../bin/console --env=prod doctrine:phpcr:repository:init');
28-
runCommand(__DIR__.'/../bin/console -v --env=prod doctrine:phpcr:fixtures:load -n');
29-
runCommand(__DIR__.'/../bin/console --env=prod cache:warmup -n --no-debug');
19+
$returnValue = null;
20+
$output = [];
21+
exec($commandFile.' '.__DIR__.'/../', $output, $returnValue);
22+
23+
if (0 !== (int) $returnValue) {
24+
outputNice('Errors on Execution:');
25+
outputNice($output);
26+
exit($returnValue);
27+
} else {
28+
outputNice($output);
29+
outputNice('Success');
30+
}

0 commit comments

Comments
 (0)