|
15 | 15 | set('identity_file', '~/.ssh/id_rsa'); |
16 | 16 | set('upgrade_path', '/container/application/upgrade'); |
17 | 17 | set('shared_path', '/container/application/shared'); |
| 18 | +set('sitehost_restart_mode', 'container'); //This can also be set to apache |
18 | 19 |
|
19 | 20 | /** |
20 | 21 | * Sitehost - this is the upgrade script from mysql 5.7 to 8 |
|
27 | 28 | throw new GracefulShutdownException('User aborted the deployment.'); |
28 | 29 | } |
29 | 30 |
|
30 | | - //1) Export current |
| 31 | + //1) Export current |
31 | 32 | writeln('mkdir to save contents - {{upgrade_path}}'); |
32 | | - run(" mkdir -p {{upgrade_path}}"); |
| 33 | + run(" mkdir -p {{upgrade_path}}"); |
33 | 34 | writeln('Export using .env details'); |
34 | 35 | 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"); |
35 | 36 | writeln('Finished exporting db'); |
|
51 | 52 | run('sed -i "s/SS_DATABASE_SERVER=\".*\"/SS_DATABASE_SERVER=\"'.$env_SS_DATABASE_SERVER.'\"/g" {{shared_path}}/.env'); |
52 | 53 | run('sed -i "s/SS_DATABASE_NAME=\".*\"/SS_DATABASE_NAME=\"'.$env_SS_DATABASE_NAME.'\"/g" {{shared_path}}/.env'); |
53 | 54 | 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'); |
55 | 56 | writeln('Finshed - go test website - if there are issues, rollback using dep sitehost:upgrade-mysql:rollback to swap .env files back'); |
56 | 57 | }); |
57 | 58 |
|
|
120 | 121 | writeln('No default custom php has been configured'); |
121 | 122 | writeln('Creating "~/container/config/php/conf.d/ps-custom.ini" and adding defaults'); |
122 | 123 | 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 |
126 | 127 | } else { |
127 | 128 | writeln('php has been configured - skipping'); |
128 | 129 | } |
|
142 | 143 |
|
143 | 144 |
|
144 | 145 | 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 | + |
145 | 156 | if (testLocally('[ -f /var/www/sitehost-api-key.txt ]')) { |
146 | 157 | $config = file_get_contents('/var/www/sitehost-api-key.txt'); |
147 | 158 | set('sitehost_api_key', trim($config)); |
|
257 | 268 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
258 | 269 | $jobResponse = curl_exec($ch); |
259 | 270 | $jobStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
260 | | - |
| 271 | + |
261 | 272 | // Decode the response and check the status |
262 | 273 | $jobStatus = json_decode($jobResponse, true); |
263 | 274 |
|
|
387 | 398 | */ |
388 | 399 | task('savefromremote:logs', function () { |
389 | 400 | writeln('<info>Retrieving specific logs from SiteHost</info>'); |
390 | | - |
| 401 | + |
391 | 402 | // Ensure the local directory exists |
392 | 403 | runLocally('mkdir -p ./from-remote/logs/apache2'); |
393 | | - |
| 404 | + |
394 | 405 | // Download silverstripe.log |
395 | 406 | writeln('<comment>Downloading silverstripe.log</comment>'); |
396 | 407 | runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/silverstripe.log ./from-remote/logs/', ['timeout' => 600]); |
397 | | - |
| 408 | + |
398 | 409 | // Download apache2/error.log |
399 | 410 | writeln('<comment>Downloading apache2/error.log</comment>'); |
400 | 411 | runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/apache2/error.log ./from-remote/logs/apache2/', ['timeout' => 600]); |
401 | | - |
| 412 | + |
402 | 413 | // Download apache2/access.log |
403 | 414 | writeln('<comment>Downloading apache2/access.log</comment>'); |
404 | 415 | runLocally('rsync -avzP {{remote_user}}@{{alias}}:/container/logs/apache2/access.log ./from-remote/logs/apache2/', ['timeout' => 600]); |
405 | | - |
| 416 | + |
406 | 417 | writeln('<info>Log retrieval completed!</info>'); |
407 | 418 | }); |
408 | 419 |
|
|
0 commit comments