xx
This commit is contained in:
+44
-17
@@ -31,7 +31,8 @@ namespace Start
|
||||
}
|
||||
|
||||
|
||||
int apiPort = 0;
|
||||
int apiPort = 7100;
|
||||
int vuePort = 9527;
|
||||
private void connectButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
string connectionString = $"Server={serverTextBox.Text};User Id={usernameTextBox.Text};Password={passwordTextBox.Text};";
|
||||
@@ -56,20 +57,20 @@ namespace Start
|
||||
{
|
||||
nginxPortTBox.Text.Trim();
|
||||
|
||||
var nginxPort = 0;
|
||||
|
||||
|
||||
if (int.TryParse(nginxPortTBox.Text, out nginxPort) == false || int.TryParse(apiPortTBox.Text, out apiPort) == false)
|
||||
if (int.TryParse(nginxPortTBox.Text, out vuePort) == false || int.TryParse(apiPortTBox.Text, out apiPort) == false)
|
||||
{
|
||||
MessageBox.Show("请输入合法的端口");
|
||||
}
|
||||
|
||||
if (IsPortInUse(nginxPort))
|
||||
if (IsPortInUse(vuePort))
|
||||
{
|
||||
MessageBox.Show("nginx 设置的端口被占用,请选择其他端口");
|
||||
MessageBox.Show("服务设置的前端端口被占用,请选择其他端口");
|
||||
}
|
||||
if (IsPortInUse(apiPort))
|
||||
{
|
||||
MessageBox.Show("服务设置的端口被占用,请选择其他端口");
|
||||
MessageBox.Show("服务设置的后端端口被占用,请选择其他端口");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -104,16 +105,42 @@ namespace Start
|
||||
private void activeBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
//string nginxPath = @"C:\nginx\nginx.exe";
|
||||
//string workingDirectory = @"C:\nginx";
|
||||
//string configFile = @"C:\nginx\conf\nginx.conf";
|
||||
#region 修改 nginx 配置文件 启动nginx
|
||||
|
||||
|
||||
var nginxConfigPath = Path.Combine(AppContext.BaseDirectory, @$"nginx-1.20.1\conf\nginx.conf");
|
||||
|
||||
if (!File.Exists(nginxConfigPath))
|
||||
{
|
||||
MessageBox.Show("预设路径不存在nginx");
|
||||
}
|
||||
|
||||
var nginxConfig = File.ReadAllText(nginxConfigPath);
|
||||
|
||||
nginxConfig= nginxConfig.Replace("9527", vuePort.ToString());
|
||||
nginxConfig= nginxConfig.Replace("7100", apiPort.ToString());
|
||||
|
||||
|
||||
|
||||
File.WriteAllText(nginxConfigPath, nginxConfig);
|
||||
|
||||
|
||||
|
||||
// 获取nginx.exe所在的目录
|
||||
string nginxPath = Path.Combine(AppContext.BaseDirectory, @$"nginx-1.20.1\");
|
||||
// 创建ProcessStartInfo对象,指定要启动的可执行文件及其参数
|
||||
ProcessStartInfo psi = new ProcessStartInfo(nginxPath + "nginx.exe");
|
||||
// 指定工作目录,即进入nginx.exe所在的目录
|
||||
psi.WorkingDirectory = nginxPath;
|
||||
// 启动可执行文件
|
||||
Process.Start(psi);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
//ProcessStartInfo psi = new ProcessStartInfo();
|
||||
//psi.FileName = nginxPath;
|
||||
//psi.WorkingDirectory = workingDirectory;
|
||||
//psi.Arguments = "-c \"" + configFile + "\"";
|
||||
|
||||
//Process.Start(psi);
|
||||
|
||||
|
||||
var configObj = new
|
||||
@@ -145,10 +172,10 @@ namespace Start
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.Start();
|
||||
|
||||
//process.StandardInput.WriteLine(Path.Combine(AppContext.BaseDirectory, "startNginx.bat"));
|
||||
|
||||
|
||||
|
||||
var cmdNginx = $"start {Path.Combine(AppContext.BaseDirectory, "nginx-1.4.7/nginx.exe")}";
|
||||
//启动nginx
|
||||
process.StandardInput.WriteLine(cmdNginx);
|
||||
|
||||
// 删除已存在的服务
|
||||
process.StandardInput.WriteLine($"sc delete {jObject["serviceName"].ToString()}");
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Platforms>AnyCPU;x86</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -13,6 +14,7 @@
|
||||
<None Remove="sql\bin.bat" />
|
||||
<None Remove="sql\data.sql" />
|
||||
<None Remove="sql\dbo.sql" />
|
||||
<None Remove="sql\startNginx.bat" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -28,6 +30,9 @@
|
||||
<Content Include="sql\dbo.sql">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="startNginx.bat">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
cd /d %~dp0\nginx-1.4.7
|
||||
start nginx.exe
|
||||
Reference in New Issue
Block a user