Skip to content

Commit 70f04ed

Browse files
committed
added restart apache option
1 parent 0716839 commit 70f04ed

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

ps_silverstripe.php

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
set('identity_file', '~/.ssh/id_rsa');
1616
set('upgrade_path', '/container/application/upgrade');
1717
set('shared_path', '/container/application/shared');
18+
set('sitehost_restart_mode', 'container'); //This can also be set to apache
1819

1920
/**
2021
* Sitehost - this is the upgrade script from mysql 5.7 to 8
@@ -27,9 +28,9 @@
2728
throw new GracefulShutdownException('User aborted the deployment.');
2829
}
2930

30-
//1) Export current
31+
//1) Export current
3132
writeln('mkdir to save contents - {{upgrade_path}}');
32-
run(" mkdir -p {{upgrade_path}}");
33+
run(" mkdir -p {{upgrade_path}}");
3334
writeln('Export using .env details');
3435
run("cd {{shared_path}} && export $(grep -v '^#' .env | xargs) && mysqldump -u \$SS_DATABASE_USERNAME -p\$SS_DATABASE_PASSWORD -h \$SS_DATABASE_SERVER --column-statistics=0 --no-tablespaces \$SS_DATABASE_NAME > {{upgrade_path}}/mysql57-backup.sql");
3536
writeln('Finished exporting db');
@@ -51,7 +52,7 @@
5152
run('sed -i "s/SS_DATABASE_SERVER=\".*\"/SS_DATABASE_SERVER=\"'.$env_SS_DATABASE_SERVER.'\"/g" {{shared_path}}/.env');
5253
run('sed -i "s/SS_DATABASE_NAME=\".*\"/SS_DATABASE_NAME=\"'.$env_SS_DATABASE_NAME.'\"/g" {{shared_path}}/.env');
5354
run('sed -i "s/SS_DATABASE_USERNAME=\".*\"/SS_DATABASE_USERNAME=\"'.$env_SS_DATABASE_USERNAME.'\"/g" {{shared_path}}/.env');
54-
run('sed -i "s/SS_DATABASE_PASSWORD=\".*\"/SS_DATABASE_PASSWORD=\"'.$env_SS_DATABASE_PASSWORD.'\"/g" {{shared_path}}/.env');
55+
run('sed -i "s/SS_DATABASE_PASSWORD=\".*\"/SS_DATABASE_PASSWORD=\"'.$env_SS_DATABASE_PASSWORD.'\"/g" {{shared_path}}/.env');
5556
writeln('Finshed - go test website - if there are issues, rollback using dep sitehost:upgrade-mysql:rollback to swap .env files back');
5657
});
5758

@@ -120,9 +121,9 @@
120121
writeln('No default custom php has been configured');
121122
writeln('Creating "~/container/config/php/conf.d/ps-custom.ini" and adding defaults');
122123
run('echo "memory_limit=512M" >> ~/container/config/php/conf.d/ps-custom.ini');
123-
//TODO: POST_MAX
124-
//TODO: EXECUTION TIME
125-
//TODO: UPLOAD_MAX
124+
//TODO: POST_MAX
125+
//TODO: EXECUTION TIME
126+
//TODO: UPLOAD_MAX
126127
} else {
127128
writeln('php has been configured - skipping');
128129
}
@@ -142,6 +143,16 @@
142143

143144

144145
task('sitehost:restart', function () {
146+
147+
//check restart mode
148+
if (get('sitehost_restart_mode') == 'apache') {
149+
writeln('<info>Restarting apache</info>');
150+
run('supervisorctl restart apache2');
151+
return;
152+
}
153+
154+
//fallback to normal
155+
145156
if (testLocally('[ -f /var/www/sitehost-api-key.txt ]')) {
146157
$config = file_get_contents('/var/www/sitehost-api-key.txt');
147158
set('sitehost_api_key', trim($config));
@@ -257,7 +268,7 @@
257268
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
258269
$jobResponse = curl_exec($ch);
259270
$jobStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
260-
271+
261272
// Decode the response and check the status
262273
$jobStatus = json_decode($jobResponse, true);
263274

@@ -387,22 +398,22 @@
387398
*/
388399
task('savefromremote:logs', function () {
389400
writeln('<info>Retrieving specific logs from SiteHost</info>');
390-
401+
391402
// Ensure the local directory exists
392403
runLocally('mkdir -p ./from-remote/logs/apache2');
393-
404+
394405
// Download silverstripe.log
395406
writeln('<comment>Downloading silverstripe.log</comment>');
396407
runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/silverstripe.log ./from-remote/logs/', ['timeout' => 600]);
397-
408+
398409
// Download apache2/error.log
399410
writeln('<comment>Downloading apache2/error.log</comment>');
400411
runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/apache2/error.log ./from-remote/logs/apache2/', ['timeout' => 600]);
401-
412+
402413
// Download apache2/access.log
403414
writeln('<comment>Downloading apache2/access.log</comment>');
404415
runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/apache2/access.log ./from-remote/logs/apache2/', ['timeout' => 600]);
405-
416+
406417
writeln('<info>Log retrieval completed!</info>');
407418
});
408419

0 commit comments

Comments
 (0)