File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import shell from 'shelljs' ;
2-
31import InstallationService from '@/service/installation' ;
42import { MySQLCredential } from '@/type/common' ;
3+ import { restartNginxService , restartPHPFPMService } from '@/util/unix' ;
54
65export default class RepairBootstrap {
76 static async handler ( directory : string , domain : string , database : MySQLCredential ) {
@@ -12,12 +11,7 @@ export default class RepairBootstrap {
1211 database
1312 ) ;
1413
15- if ( shell . exec ( `systemctl restart nginx` ) . code !== 0 ) {
16- throw new Error ( 'Failed to restart php service' ) ;
17- }
18-
19- if ( shell . exec ( `systemctl restart php${ phpVer } -fpm` ) . code !== 0 ) {
20- throw new Error ( 'Failed to restart php service' ) ;
21- }
14+ restartNginxService ( ) ;
15+ restartPHPFPMService ( phpVer ) ;
2216 }
2317}
Original file line number Diff line number Diff line change 11import fs from 'fs' ;
22import path from 'path' ;
33import { rimrafSync } from 'rimraf' ;
4- import shell from 'shelljs' ;
54
65import HTTPService from '@/service/http' ;
76import InstallationService from '@/service/installation' ;
87import { MySQLCredential , WPTemplate } from '@/type/common' ;
8+ import { restartNginxService , restartPHPFPMService } from '@/util/unix' ;
99import { unzip } from '@/util/zip' ;
1010
1111export default class SetupBootstrap {
@@ -58,12 +58,7 @@ export default class SetupBootstrap {
5858 database
5959 ) ;
6060
61- if ( shell . exec ( `systemctl restart nginx` ) . code !== 0 ) {
62- throw new Error ( 'Failed to restart php service' ) ;
63- }
64-
65- if ( shell . exec ( `systemctl restart php${ phpVer } -fpm` ) . code !== 0 ) {
66- throw new Error ( 'Failed to restart php service' ) ;
67- }
61+ restartNginxService ( ) ;
62+ restartPHPFPMService ( phpVer ) ;
6863 }
6964}
Original file line number Diff line number Diff line change 1+ export default class RestartServiceError extends Error { }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import shell from 'shelljs';
33import { getPHPErrorLogPath } from './path' ;
44
55import PHPVersionNotFoundError from '@/error/PHPVersionNotFoundError' ;
6+ import RestartServiceError from '@/error/RestartServiceError' ;
67
78export function isPHPInstalled ( ) {
89 return shell . which ( 'php' ) ;
@@ -12,6 +13,18 @@ export function isMySQLInstalled() {
1213 return shell . which ( 'mysqld' ) ;
1314}
1415
16+ export function restartNginxService ( ) {
17+ if ( shell . exec ( `systemctl restart nginx` ) . code !== 0 ) {
18+ throw new RestartServiceError ( 'nginx' ) ;
19+ }
20+ }
21+
22+ export function restartPHPFPMService ( phpVer : string ) {
23+ if ( shell . exec ( `systemctl restart php${ phpVer } -fpm` ) . code !== 0 ) {
24+ throw new RestartServiceError ( 'php-fpm' ) ;
25+ }
26+ }
27+
1528export function createPHPErrorLogFile ( phpVer : string , identity : string ) {
1629 const path = getPHPErrorLogPath ( phpVer , identity ) ;
1730 shell . touch ( path ) ;
You can’t perform that action at this time.
0 commit comments