예제 #1
0
        /// <summary>
        /// Writes PID to the runtime folder
        /// </summary>
        internal void WritePID()
        {
            lock (_lockObject)
            {
                if (!_pidIsWritten)
                {
                    string currentDirectory = Directory.GetCurrentDirectory();
                    string path             = Path.Combine(currentDirectory, _reefFileNames.GetPidFileName());

                    try
                    {
                        var pid = Process.GetCurrentProcess().Id;
                        using (StreamWriter sw = File.CreateText(path))
                        {
                            sw.WriteLine(pid);
                            sw.Flush();
                        }

                        Logger.Log(Level.Verbose, "Writing PID {0} to file {1}", pid, path);
                        _pidIsWritten = true;
                    }
                    catch (IOException e)
                    {
                        Utilities.Diagnostics.Exceptions.Caught(e, Level.Error, Logger);
                    }
                }
            }
        }