Exemple #1
0
        }         // proc Dispose

        #endregion

        #region -- Create Connection ------------------------------------------------------

        private Stream CreateConnection(Socket sNew)
        {
            var c = new ConnectionTcp(this, sNew);

            connections.Add(c);
            return(c);
        }         // func CreateConnection
Exemple #2
0
        }         // proc StartJob

        public Task ExecuteJobAsync(ICronJobExecute job, CancellationToken cancellation)
        {
            using (currentJobs.EnterWriteLock())
            {
                if (currentJobs.FindIndex(c => job == c.Job) >= 0)
                {
                    throw new InvalidOperationException("Job is already running.");
                }

                using (currentJobs.EnterReadLock())
                {
                    foreach (var j in currentJobs)
                    {
                        if (!job.CanRunParallelTo(j.Job))
                        {
                            throw new InvalidOperationException(String.Format("Job is blocked (job: {0})", j.Job.DisplayName));
                        }
                    }
                }

                Log.Info("jobstart: {0}", job.DisplayName);
                var currentJob = new CurrentRunningJob(this, job, cancellation);
                currentJobs.Add(currentJob);
                return(currentJob.Task);
            }
        }         // func ExecuteJobAsync
Exemple #3
0
        private XElement HttpDumpAction(bool mini = false)
        {
            // check for the procdump.exe
            var procDump = Config.Element(xnServer)?.GetAttribute("procdump", String.Empty);

            if (String.IsNullOrEmpty(procDump) || !File.Exists(procDump))
            {
                throw new ArgumentException("procdump.exe is not available.");
            }

            // prepare arguments
            var sbArgs = new StringBuilder();

            if (!mini)
            {
                sbArgs.Append("-ma ");                                 // dump all
            }
            sbArgs.Append("-o ");                                      // overwrite existing dump
            sbArgs.Append("-accepteula ");                             // accept eula
            sbArgs.Append(Process.GetCurrentProcess().Id).Append(' '); // process id

            // create the dump in the temp directory
            DumpFileInfo fi;

            using (dumpFiles.EnterWriteLock())
            {
                var newId = ++lastDumpFileInfoId;
                dumpFiles.Add(fi = new DumpFileInfo(newId, Path.Combine(Path.GetTempPath(), $"DEServer_{newId:000}.dmp")));
            }

            sbArgs.Append(fi.FileName);

            // prepare calling procdump
            ProcessStartInfo psi = new ProcessStartInfo(procDump, sbArgs.ToString());

            psi.UseShellExecute        = false;
            psi.RedirectStandardOutput = true;
            using (var p = Process.Start(psi))
            {
                if (!p.WaitForExit(5 * 60 + 1000))
                {
                    p.Kill();
                }

                var outputText = p.StandardOutput.ReadToEnd();

                return(DEConfigItem.SetStatusAttributes(
                           new XElement("return",
                                        new XAttribute("id", fi.Id),
                                        new XAttribute("exitcode", p.ExitCode)
                                        ),
                           p.ExitCode > 0,
                           outputText
                           ));
            }
        }         // proc HttpDumpAction
Exemple #4
0
        }         // LoadScript

        #endregion

        #region -- Script Verwaltung ------------------------------------------------------

        private void AddScript(LuaScript script)
        {
            lock (scripts)
            {
                if (FindScript(script.ScriptId) != null)
                {
                    throw new IndexOutOfRangeException(String.Format("ScriptId '{0}' is not unique.", script.ScriptId));
                }

                scripts.Add(script);
            }
        }         // proc AddScript
Exemple #5
0
        public ILuaAttachedScript AttachScript(string scriptId, LuaTable table, bool autoRun)
        {
            using (EnterReadLock())
            {
                // Gibt es die Verbindung schon
                lock (globals)
                {
                    foreach (var c in globals)
                    {
                        if (String.Compare(c.ScriptId, scriptId, true) == 0 && c.LuaTable == table)
                        {
                            return(c);
                        }
                    }
                }

                // Lege die Verbindung an
                var ag = new LuaAttachedGlobal(this, scriptId, table, autoRun);
                lock (globals)
                    globals.Add(ag);
                return(ag);
            }
        }         // func AttachScript
Exemple #6
0
 private void AddEventSession(EventSession eventSession)
 => eventSessions.Add(eventSession);
Exemple #7
0
 private void AddEventSession(EventSession eventSession)
 {
     using (eventSessions.EnterWriteLock())
         eventSessions.Add(eventSession);
 }         // proc AddEventSession