Esempio n. 1
0
        static string ExecCmd(string m, Dictionary <string, string> a)
        {
            try
            {
                //ProcessWatcher.OnStop();
                switch (m)
                {
                case "startall":
                    ProcessWatcher.OnStop();

                    efwplusHttpManager.StartHttp();
                    MongodbManager.StartDB();
                    NginxManager.StartWeb();

                    efwplusBaseManager.StartBase();
                    efwplusRouteManager.StartRoute();
                    efwplusWebAPIManager.StartAPI();

                    ProcessWatcher.OnStart();
                    break;

                case "quitall":
                    ProcessWatcher.OnStop();

                    efwplusHttpManager.StopHttp();
                    efwplusBaseManager.StopBase();
                    efwplusRouteManager.StopRoute();
                    efwplusWebAPIManager.StopAPI();
                    MongodbManager.StopDB();
                    NginxManager.StopWeb();
                    break;

                case "exit":
                    ProcessWatcher.OnStop();

                    efwplusHttpManager.StopHttp();
                    efwplusBaseManager.StopBase();
                    efwplusRouteManager.StopRoute();
                    efwplusWebAPIManager.StopAPI();
                    MongodbManager.StopDB();
                    NginxManager.StopWeb();
                    Process.GetCurrentProcess().Kill();
                    break;

                case "restart":
                    ProcessWatcher.OnStop();

                    efwplusBaseManager.StopBase();
                    efwplusRouteManager.StopRoute();
                    efwplusWebAPIManager.StopAPI();
                    MongodbManager.StopDB();
                    NginxManager.StopWeb();

                    Application.Restart();
                    Process.GetCurrentProcess().Kill();
                    //MongodbManager.StartDB();
                    //NginxManager.StartWeb();

                    //efwplusBaseManager.StartBase();
                    //efwplusRouteManager.StartRoute();
                    //efwplusWebAPIManager.StartAPI();

                    break;

                case "restartbase":
                    efwplusBaseManager.StopBase();
                    efwplusBaseManager.StartBase();
                    break;

                case "restartroute":
                    efwplusRouteManager.StopRoute();
                    efwplusRouteManager.StartRoute();
                    break;

                case "restartwebapi":
                    efwplusWebAPIManager.StopAPI();
                    efwplusWebAPIManager.StartAPI();
                    break;

                case "restartmongodb":
                    MongodbManager.StopDB();
                    MongodbManager.StartDB();
                    break;

                case "restartnginx":
                    NginxManager.StopWeb();
                    NginxManager.StartWeb();
                    break;

                case "upgradeplugin":                                                               //升级插件
                    if (EFWCoreLib.CoreFrame.Init.HostSettingConfig.GetValue("autoupdater") == "1") //是否启动自动升级程序
                    {
                        showmsg("准备升级插件...");
                        ExecCmd("quitall", null);
                        try
                        {
                            efwplusHosting.UpgradeProgram.SetUpPluginUpgrade();
                        }
                        catch (Exception err)
                        {
                            showmsg("升级插件失败!" + err.Message + err.StackTrace);
                            showmsg("程序服务未启动.");
                            //Process.GetCurrentProcess().Kill();
                            //host.RunState = HostState.NoOpen;
                        }

                        showmsg("升级插件完成,正在启动服务...");
                        ExecCmd("startall", null);
                    }
                    else
                    {
                        showmsg("自动升级插件没有开启!");
                    }
                    break;
                }
                //ProcessWatcher.OnStart();
                return("succeed");
            }
            catch (Exception e)
            {
                showmsg(e.Message + e.StackTrace);
                return(e.Message);
            }
        }