File tree Expand file tree Collapse file tree 6 files changed +30
-16
lines changed
Expand file tree Collapse file tree 6 files changed +30
-16
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ public static void Deploy(Argument argument)
7272 Helper . Replicate ( packages , root ) ;
7373
7474 //启动宿主程序
75- Launcher . Launch ( root , argument ) ;
75+ Launcher . Launch ( deployment , argument ) ;
7676 }
7777 #endregion
7878
Original file line number Diff line number Diff line change @@ -42,8 +42,6 @@ public interface ILauncher
4242 string Name { get ; }
4343
4444 /// <summary>启动宿主应用程序。</summary>
45- /// <param name="root">宿主应用程序的根目录。</param>
4645 /// <param name="argument">部署器的调用参数。</param>
47- /// <returns>如果启动成功则返回真(<c>True</c>),否则返回假(<c>False</c>)。</returns>
48- bool Launch ( string root , Deployer . Argument argument ) ;
46+ void Launch ( Deployer . Argument argument ) ;
4947}
Original file line number Diff line number Diff line change 3232 */
3333
3434using System ;
35+ using System . IO ;
3536using System . Diagnostics ;
3637
3738namespace Zongsoft . Upgrading ;
@@ -41,9 +42,8 @@ partial class Launcher
4142 private sealed class DaemonLauncher : ILauncher
4243 {
4344 public string Name => "Daemon" ;
44- public bool Launch ( string root , Deployer . Argument argument )
45+ public void Launch ( Deployer . Argument argument )
4546 {
46- return false ;
4747 }
4848 }
4949}
Original file line number Diff line number Diff line change 3232 */
3333
3434using System ;
35+ using System . IO ;
3536using System . Diagnostics ;
3637
3738namespace Zongsoft . Upgrading ;
@@ -41,9 +42,16 @@ partial class Launcher
4142 private sealed class DefaultLauncher : ILauncher
4243 {
4344 public string Name => string . Empty ;
44- public bool Launch ( string root , Deployer . Argument argument )
45+ public void Launch ( Deployer . Argument argument )
4546 {
46- return false ;
47+ var info = new ProcessStartInfo ( argument . AppPath )
48+ {
49+ WindowStyle = ProcessWindowStyle . Normal ,
50+ WorkingDirectory = Path . GetDirectoryName ( argument . AppPath ) ,
51+ } ;
52+
53+ //启动升级部署器程序
54+ Process . Start ( info ) ;
4755 }
4856 }
4957}
Original file line number Diff line number Diff line change 3232 */
3333
3434using System ;
35+ using System . IO ;
3536using System . Diagnostics ;
3637
3738namespace Zongsoft . Upgrading ;
@@ -41,9 +42,8 @@ partial class Launcher
4142 private sealed class WebLauncher : ILauncher
4243 {
4344 public string Name => "Web" ;
44- public bool Launch ( string root , Deployer . Argument argument )
45+ public void Launch ( Deployer . Argument argument )
4546 {
46- return false ;
4747 }
4848 }
4949}
Original file line number Diff line number Diff line change 3232 */
3333
3434using System ;
35+ using System . IO ;
3536using System . Collections . Generic ;
3637
3738namespace Zongsoft . Upgrading ;
@@ -65,22 +66,29 @@ static Launcher()
6566 #endregion
6667
6768 #region 公共方法
68- public static bool Launch ( string root , Deployer . Argument argument )
69+ public static void Launch ( Deployer . Deployment deployment , Deployer . Argument argument )
6970 {
70- if ( string . IsNullOrEmpty ( root ) || argument == null )
71- return false ;
71+ if ( argument == null || deployment == null )
72+ return ;
7273
7374 try
7475 {
76+ //根据宿主应用类型获取对应的启动器
7577 if ( _launchers . TryGetValue ( argument . AppType ?? string . Empty , out var launcher ) )
76- return launcher . Launch ( root , argument ) ;
78+ launcher . Launch ( argument ) ;
7779 else
78- return Default . Launch ( root , argument ) ;
80+ Default . Launch ( argument ) ;
81+
82+ //释放部署文件(解除排他性锁)
83+ deployment . Dispose ( ) ;
84+
85+ //删除部署文件
86+ if ( File . Exists ( argument . Deployment ) )
87+ File . Delete ( argument . Deployment ) ;
7988 }
8089 catch ( Exception ex )
8190 {
8291 Zongsoft . Diagnostics . Logging . GetLogging < Program > ( ) . Error ( ex ) ;
83- return false ;
8492 }
8593 }
8694 #endregion
You can’t perform that action at this time.
0 commit comments