@@ -634,7 +634,7 @@ export class PayaraServerInstanceController extends PayaraInstanceController {
634634 }
635635
636636
637- public async startServer ( payaraServer : PayaraLocalServerInstance , debug : boolean , debugPort : string , callback ?: ( status : boolean ) => any ) : Promise < void > {
637+ public async startServer ( payaraServer : PayaraLocalServerInstance , debug : boolean , debugPort : string | number | undefined , callback ?: ( status : boolean ) => any ) : Promise < void > {
638638 if ( ! payaraServer . isStopped ( ) ) {
639639 vscode . window . showErrorMessage ( 'Payara Server instance already running.' ) ;
640640 return ;
@@ -744,6 +744,25 @@ export class PayaraServerInstanceController extends PayaraInstanceController {
744744 } ) ;
745745 }
746746
747+ private async stopAndStartInDebugMode ( payaraServer : PayaraLocalServerInstance , debugPort : string | number | undefined , callback ?: ( status : boolean ) => any ) : Promise < void > {
748+ let endpoints : RestEndpoints = new RestEndpoints ( payaraServer ) ;
749+ endpoints . invoke ( "stop-domain" , async ( _res ) => {
750+ payaraServer . setState ( InstanceState . STOPPED ) ;
751+ payaraServer . setDebug ( false ) ;
752+ await new Promise ( resolve => setTimeout ( resolve , 2000 ) ) ;
753+ this . refreshServerList ( ) ;
754+ payaraServer . disconnectOutput ( ) ;
755+ this . startServer ( payaraServer , true , debugPort , callback ) ;
756+ } ,
757+ ( _res , message ) => {
758+ vscode . window . showErrorMessage ( 'Unable to stop the Payara Server before restarting in debug mode. ' + message ) ;
759+ if ( callback ) {
760+ callback ( false ) ;
761+ }
762+ }
763+ ) ;
764+ }
765+
747766 public async renameServer ( payaraServer : PayaraServerInstance ) : Promise < void > {
748767 if ( payaraServer ) {
749768 await vscode . window . showInputBox ( {
@@ -848,7 +867,7 @@ export class PayaraServerInstanceController extends PayaraInstanceController {
848867 if ( server instanceof PayaraLocalServerInstance && ! server . isStarted ( ) ) {
849868 this . startServer ( server , debug , debugPort , deploy ) ;
850869 } else if ( server instanceof PayaraLocalServerInstance && debug && ! server . isDebug ( ) ) {
851- this . restartServer ( server , debug , deploy ) ;
870+ this . stopAndStartInDebugMode ( server , debugPort , deploy ) ;
852871 } else {
853872 deploy ( true ) ;
854873 }
@@ -1137,4 +1156,4 @@ interface State {
11371156 username : string ;
11381157 password : string ;
11391158 name : string ;
1140- }
1159+ }
0 commit comments