@@ -28,6 +28,7 @@ export default class Webdav extends Command {
2828
2929 let message = '' ;
3030 let success = true ;
31+ await PM2Utils . connect ( ) ;
3132 switch ( args . action ) {
3233 case 'enable' : {
3334 message = await this . enableWebDav ( ) ;
@@ -55,6 +56,7 @@ export default class Webdav extends Command {
5556 break ;
5657 }
5758 }
59+ PM2Utils . disconnect ( ) ;
5860 return { success, message, action : args . action } ;
5961 } ;
6062
@@ -71,7 +73,6 @@ export default class Webdav extends Command {
7173 private enableWebDav = async ( ) : Promise < string > => {
7274 CLIUtils . doing ( 'Starting Internxt WebDav server...' ) ;
7375 await DriveDatabaseManager . clean ( ) ;
74- await PM2Utils . connect ( ) ;
7576 await PM2Utils . killWebDavServer ( ) ;
7677 await PM2Utils . startWebDavServer ( ) ;
7778 CLIUtils . done ( ) ;
@@ -98,7 +99,6 @@ export default class Webdav extends Command {
9899
99100 private disableWebDav = async ( ) : Promise < string > => {
100101 CLIUtils . doing ( 'Stopping Internxt WebDav server...' ) ;
101- await PM2Utils . connect ( ) ;
102102 await PM2Utils . killWebDavServer ( ) ;
103103 CLIUtils . done ( ) ;
104104 const message = 'Internxt WebDav server stopped successfully' ;
@@ -109,7 +109,6 @@ export default class Webdav extends Command {
109109 private restartWebDav = async ( ) : Promise < string > => {
110110 CLIUtils . doing ( 'Restarting Internxt WebDav server...' ) ;
111111 await DriveDatabaseManager . clean ( ) ;
112- await PM2Utils . connect ( ) ;
113112 const { status } = await PM2Utils . webdavServerStatus ( ) ;
114113 if ( status === 'online' ) {
115114 await PM2Utils . killWebDavServer ( ) ;
@@ -120,14 +119,13 @@ export default class Webdav extends Command {
120119 return message ;
121120 } else {
122121 CLIUtils . done ( ) ;
123- const message = 'Internxt WebDav server is not running, cannot restart ' ;
124- CLIUtils . error ( this . log . bind ( this ) , message ) ;
122+ const message = 'Internxt WebDav server is not running, it wont be restarted ' ;
123+ CLIUtils . warning ( this . log . bind ( this ) , message ) ;
125124 return message ;
126125 }
127126 } ;
128127
129128 private webDAVStatus = async ( ) : Promise < string > => {
130- await PM2Utils . connect ( ) ;
131129 const { status } = await PM2Utils . webdavServerStatus ( ) ;
132130 const message = `Internxt WebDAV server status: ${ status } ` ;
133131 CLIUtils . log ( this . log . bind ( this ) , message ) ;
0 commit comments