电脑服务器重启怎么弄,第1张

电脑服务器重新启动的话,我所知道的是三种方法。第一种方法是关闭电源键,长按电源键以后电脑就会关闭。第二种方法就是点击电脑左下角的菜单,选择关闭选项里面的重新启动选项,第三方法就是按ctrl+ A L T +del键,可以重启。

直接给你一个现成代码吧,实测套用后可行,直接将站点链接输进去就行:

using JinherAMPBTPDeploy;

using MicrosoftWebAdministration;

using RedisHelper;

using System;

using SystemCollectionsGeneric;

using SystemConfiguration;

using SystemIO;

using SystemLinq;

using SystemText;

using SystemThreading;

using SystemThreadingTasks;

namespace Redis

{

public class Program

{

static readonly string AppPoolName = ConfigurationManagerAppSettings["ApplicationPoolName"]ToString();

static readonly string WebSiteName = ConfigurationManagerAppSettings["WebSiteName"]ToString();

static readonly int SleepTime = intParse(ConfigurationManagerAppSettings["SleepTime"]ToString());

static ServerManager sm;

static void Main(string[] args)

{

ConsoleWriteLine($"检测程序启动,{WebSiteName}当网站或其应用池停下后,会自动启动。");

sm = new ServerManager();

new Thread(RecoveryWebSite)Start();

}

static void RecoveryWebSite()

{

while (true)

{

try

{

var pool = smApplicationPools[AppPoolName];

if (pool != null && poolState == ObjectStateStopped)

{

ConsoleWriteLine("检测到应用池" + AppPoolName + "停止服务");

ConsoleWriteLine("正在启动应用池" + AppPoolName);

if (poolStart() == ObjectStateStarted)

{

ConsoleWriteLine("成功启动应用池" + AppPoolName);

}

else

{

ConsoleWriteLine("启动应用池" + AppPoolName + "失败 " + SleepTime / 60 + "秒后重试启动");

}

}

var site = smSites[WebSiteName];

if (site != null && siteState == ObjectStateStopped)

{

ConsoleWriteLine("检测到网站" + WebSiteName + "停止服务");

ConsoleWriteLine("正在启动网站" + WebSiteName);

if (siteStart() == ObjectStateStarted)

{

ConsoleWriteLine("成功启动网站" + WebSiteName);

}

else

{

ConsoleWriteLine("启动网站" + WebSiteName + "失败 " + SleepTime / 60 + "秒后重试启动");

}

}

}

catch (Exception ex)

{

ConsoleWriteLine(exMessageToString());

}

GCCollect();

ThreadSleep(SleepTime);

}

}

}

}

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » 电脑服务器重启怎么弄

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情