You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.9 KiB
80 lines
2.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sog;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
using Google.Protobuf;
|
|
using Sog.ClusterCfg;
|
|
|
|
namespace SMCenter
|
|
{
|
|
|
|
public enum DisableMode{ open = 0, close = 1 };
|
|
|
|
public class SMProcApp
|
|
{
|
|
public string Name { get; private set; }
|
|
|
|
public uint AppId { get; private set; }
|
|
public int AppType { get; private set; }
|
|
public int Sequence { get; private set; }
|
|
public int StopTimeout { get; private set; }
|
|
public string ServerIDStr { get; private set; }
|
|
|
|
public string Cmd { get; private set; }
|
|
public string WorkPath { get; private set; }
|
|
public string CfgPath { get; private set; }
|
|
public string HostName { get; private set; }
|
|
public string ExeFileName { get; private set; }
|
|
public string ScriptName { get; private set; }
|
|
public DisableMode Disable { get; private set; }
|
|
|
|
public HostConfig HostConfig { get; private set; }
|
|
|
|
public static SMProcApp CreateApp(BusinessConfig business, HostConfig host,
|
|
GroupProcConfig proc, AppConfig app,bool isworldlayer)
|
|
{
|
|
SMProcApp smprocApp = new SMProcApp();
|
|
Dictionary<string, string> paramsMap = new Dictionary<string, string>();
|
|
|
|
smprocApp.Name = app.name;
|
|
smprocApp.AppType = app.apptype;
|
|
smprocApp.Sequence = app.sequence;
|
|
smprocApp.StopTimeout = app.stoptimeout;
|
|
smprocApp.Disable = DisableMode.open;
|
|
smprocApp.CfgPath = host.cfgpath;
|
|
smprocApp.HostName = host.hostname;
|
|
smprocApp.HostConfig = host;
|
|
smprocApp.WorkPath = business.workpath;
|
|
smprocApp.ExeFileName = "SogLoader";
|
|
smprocApp.ScriptName = app.script;
|
|
ClusterApp.ParseParams(proc.param, paramsMap);
|
|
ClusterApp.ParseParams(host.param, paramsMap);
|
|
if (paramsMap.ContainsKey("workPath") ){
|
|
smprocApp.WorkPath = paramsMap["workPath"];
|
|
}
|
|
if (paramsMap.ContainsKey("exeFileName"))
|
|
{
|
|
smprocApp.ExeFileName = paramsMap["exeFileName"];
|
|
}
|
|
if (paramsMap.ContainsKey("Disable") && paramsMap["Disable"] == "close")
|
|
{
|
|
smprocApp.Disable = DisableMode.close;
|
|
}
|
|
int worldid = host.worldid;
|
|
if(isworldlayer == false)
|
|
{
|
|
worldid = 0;
|
|
}
|
|
|
|
smprocApp.AppId = ServerIDUtils.MakeServerID(worldid, app.apptype, proc.instid);
|
|
smprocApp.ServerIDStr = ServerIDUtils.IDToString(smprocApp.AppId);
|
|
smprocApp.Cmd = string.Format("./SogLoader --id={0} --cluster={1}/cluster.json", smprocApp.ServerIDStr, host.cfgpath);
|
|
|
|
|
|
return smprocApp;
|
|
}
|
|
}
|
|
}
|
|
|