Skip to content

Commit 56aef07

Browse files
committed
调整启动器。 🏮
1 parent e51b8a4 commit 56aef07

File tree

6 files changed

+30
-16
lines changed

6 files changed

+30
-16
lines changed

upgrading/deployer/Deployer.Deploy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

upgrading/deployer/ILauncher.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff 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
}

upgrading/deployer/Launcher.Daemon.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333

3434
using System;
35+
using System.IO;
3536
using System.Diagnostics;
3637

3738
namespace 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
}

upgrading/deployer/Launcher.Default.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333

3434
using System;
35+
using System.IO;
3536
using System.Diagnostics;
3637

3738
namespace 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
}

upgrading/deployer/Launcher.Web.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333

3434
using System;
35+
using System.IO;
3536
using System.Diagnostics;
3637

3738
namespace 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
}

upgrading/deployer/Launcher.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
*/
3333

3434
using System;
35+
using System.IO;
3536
using System.Collections.Generic;
3637

3738
namespace 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

0 commit comments

Comments
 (0)