Example #1
0
        static void Main(string[] args)
        {
            WritePassedArgsToLog(args);

            var configuration = GetConfiguration() ?? new Configuration {
                Port = DEFAULT_PORT
            };

            /*
             * sample configuration:
             *
             * {
             * "Path":  "c:\\developer\\sergueik\\external\\angular-master",
             * "Port": 8080
             * }
             *
             */
            StaticContentController.SiteRootPath = PathNormalizer.NormalizePath(configuration.Path);
            var port = configuration.Port;

            Logger.InfoFormat("Starting...\r\nPort = {0}\r\nPath = {1}", port, StaticContentController.SiteRootPath);

            var serviceName  = Assembly.GetEntryAssembly().GetName().Name + "_Port_" + port;
            var microService = new MicroService(port, serviceName, serviceName);

            microService.Run(args);
        }
Example #2
0
        /// <summary>
        /// Gets the configuration.
        /// </summary>
        /// <returns></returns>
        private static Configuration GetConfiguration()
        {
            Configuration configuration  = null;
            var           configFilePath = PathNormalizer.NormalizePath(CONFIG_FILE_NAME);

            if (!File.Exists(configFilePath))
            {
                return(null);
            }

            var jsonConfig = GetConfigAsJson(configFilePath);

            try
            {
                configuration = JsonConvert.DeserializeObject <Configuration>(jsonConfig);
                Logger.Info("Configuration parsed");

                if (configuration.Port == 0)
                {
                    Logger.Info("No configuration port found. using port " + DEFAULT_PORT);
                    configuration.Port = DEFAULT_PORT;
                }
            }
            catch (Exception exception)
            {
                Logger.Error("Exception occured in configuratin parsing", exception);
            }

            return(configuration);
        }
Example #3
0
        /// <summary>
        /// Mains the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        static void Main(string[] args)
        {
            WritePassedArgsToLog(args);

            arguments = args;



            var configuration = GetConfiguration() ?? new Configuration {
                Port = DEFAULT_PORT
            };

            if (configuration.doDisableLogFiles)
            {
                HostMe.Logger.rollingFileAppender.Close();
            }



            StaticContentController.SiteRootPath = PathNormalizer.NormalizePath(configuration.Path);
            var port = configuration.Port;

            if (configuration.doAutoSelectUnusedPort)
            {
                port = GetOpenPort(port);
            }



            Logger.InfoFormat("Starting...\r\nPort = {0}\r\nPath = {1}", port, StaticContentController.SiteRootPath);

            var serviceName = Assembly.GetEntryAssembly().GetName().Name + "_Port_" + port;



            service = new MicroService(port, serviceName, serviceName);

            Thread secondThread = new Thread(runService);

            secondThread.Start();



            if (configuration.doAutoOpenDefaultBrowser)
            {
                tryOpenUrl("http://localhost:" + port);
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            WritePassedArgsToLog(args);

            var configuration = GetConfiguration() ?? new Configuration {
                Port = DEFAULT_PORT
            };

            StaticContentController.SiteRootPath = PathNormalizer.NormalizePath(configuration.Path);
            var port = configuration.Port;

            Logger.InfoFormat("Starting...\r\nPort = {0}\r\nPath = {1}", port, StaticContentController.SiteRootPath);

            var serviceName  = Assembly.GetEntryAssembly().GetName().Name + "_Port_" + port;
            var microService = new MicroService(port, serviceName, serviceName);

            microService.Run(args);
        }
Example #5
0
        private static IAppender CreateRollingFileAppender(ILayout layout)
        {
            var logsFolder = PathNormalizer.NormalizePath("logs");

            if (!Directory.Exists(logsFolder))
            {
                Directory.CreateDirectory(logsFolder);
            }

            var rollingFileAppender = new RollingFileAppender
            {
                Layout       = layout,
                AppendToFile = true,
                RollingStyle = RollingFileAppender.RollingMode.Size,
                PreserveLogFileNameExtension = true,
                MaxSizeRollBackups           = 1,
                MaximumFileSize   = "10MB",
                StaticLogFileName = true,
                File = Path.Combine(logsFolder, DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt")
            };

            rollingFileAppender.ActivateOptions();
            return(rollingFileAppender);
        }