コード例 #1
0
ファイル: Program.cs プロジェクト: ShadyWhite/Milvaneth
        private static void SetupEnvironment(string[] args)
        {
#if DEBUG_PARAMTER
#warning DebugVal
            _parentPid = -1;                            // -p 1234
            _gamePid   = Helper.GetProcess()?.Id ?? -1; // -g 1234
            //_gamePid = -1;
            _dataBusId = -1;                            // -b 1234
            _venvId    = -1;                            // -v 1234
            _debugLog  = false;                         // --debug
            _logLines  = true;                          // --chatlog

            //_parentPid = 28340;
            //_gamePid = -1;
            //_logLines = false;
            //_debugLog = false;
            //_dataBusId = 2032234920;
            //_venvId = 614562325;
#else
            _parentPid = int.MinValue; // -p 1234, gui process id, -1 = don't watch
            _gamePid   = int.MinValue; // -g 1234, game process id, -1 = wait next
            _dataBusId = int.MinValue; // -b 1234, data bus id
            _venvId    = int.MinValue; // -v 1234, virtual env id, -1 = don't use
            _debugLog  = false;        // --debug, log debug information to file
            _logLines  = false;        // --chatlog, enable chatlog logging (enable debugLog to log to file)
            // don't consider recycle slave instance, just run another

            var p = new OptionSet()
                    .Add("p=", v => _parentPid     = int.Parse(v))
                    .Add("g=", v => _gamePid       = int.Parse(v))
                    .Add("b=", v => _dataBusId     = int.Parse(v))
                    .Add("v=", v => _venvId        = int.Parse(v))
                    .Add("debug", v => _debugLog   = true)
                    .Add("chatlog", v => _logLines = true);
            p.Parse(args);

            if (_parentPid == int.MinValue || _gamePid == int.MinValue || _dataBusId == int.MinValue || _venvId == int.MinValue)
            {
                Environment.Exit(0);
            }
#endif

            _currentPid = Process.GetCurrentProcess().Id;
            Logger.Initialize(_debugLog, _logLines);

            Log.Fatal(
                $"Process Start: Type Slave /" +
                $" ProcId {_currentPid} /" +
                $" ParId {_parentPid} /" +
                $" GameId {_gamePid} /" +
                $" BusId {_dataBusId} /" +
                $" Debug {_debugLog} /" +
                $" Chat {_logLines}");

            Helper.SetMilFileVenv(_venvId);
            IpcClient.EnsureBus(_dataBusId);
        }