@@ -562,22 +562,20 @@ export class Winboat {
562562 this . containerActionLoading . value = false ;
563563 }
564564
565- async replaceCompose ( composeConfig : ComposeConfig ) {
565+ async replaceCompose ( composeConfig : ComposeConfig , restart = true ) {
566566 logger . info ( "Going to replace compose config" ) ;
567567 this . containerActionLoading . value = true ;
568568
569569 const composeFilePath = path . join ( WINBOAT_DIR , 'docker-compose.yml' ) ;
570-
571- // 0. Stop the current container if it's online
572- if ( this . containerStatus . value === ContainerStatus . Running ) {
573- await this . stopContainer ( ) ;
570+
571+ if ( restart ) {
572+ // 1. Compose down the current container
573+ await execAsync ( `docker compose -f ${ composeFilePath } down` ) ;
574574 }
575575
576- // 1. Compose down the current container
577- await execAsync ( `docker compose -f ${ composeFilePath } down` ) ;
578-
579576 // 2. Create a backup directory if it doesn't exist
580577 const backupDir = path . join ( WINBOAT_DIR , 'backup' ) ;
578+
581579 if ( ! fs . existsSync ( backupDir ) ) {
582580 fs . mkdirSync ( backupDir ) ;
583581 logger . info ( `Created compose backup dir: ${ backupDir } ` )
@@ -592,10 +590,13 @@ export class Winboat {
592590 const newComposeYAML = PrettyYAML . stringify ( composeConfig ) . replaceAll ( "null" , "" ) ;
593591 fs . writeFileSync ( composeFilePath , newComposeYAML , { encoding : 'utf8' } ) ;
594592 logger . info ( `Wrote new compose file to: ${ composeFilePath } ` ) ;
595-
596- // 5. Deploy the container with the new compose file
597- await execAsync ( `docker compose -f ${ composeFilePath } up -d` ) ;
598-
593+
594+ if ( restart ) {
595+ // 5. Deploy the container with the new compose file
596+ await execAsync ( `docker compose -f ${ composeFilePath } up -d` ) ;
597+ remote . getCurrentWindow ( ) . reload ( ) ;
598+ }
599+
599600 logger . info ( "Replace compose config completed, successfully deployed new container" ) ;
600601
601602 this . containerActionLoading . value = false ;
0 commit comments