public void ScenarioSqlite() { this.ObjectGraphComposer = (c) => { this.WireupSqliteTestserver(c); this.WireupGenericTestClasses(c); }; }
public void ScenarioPostgres() { this.ObjectGraphComposer = (c) => { this.WireupPostgresServer(c); this.WireupGenericTestClasses(c); }; }
public RainyStandaloneServer(string listen_url, ComposeObjectGraphDelegate composer) { logger = LogManager.GetLogger (this.GetType ()); this.appHost = new AppHost(composer); ListenUrl = listen_url; }
public RainyStandaloneServer(string listen_url, ComposeObjectGraphDelegate composer) { logger = LogManager.GetLogger(this.GetType()); this.appHost = new AppHost(composer); ListenUrl = listen_url; }
public RainyTestServer(ComposeObjectGraphDelegate composer = null) { if (composer == null) { // specifies which default scenario to use this.ScenarioSqlite(); } rainyServer = new RainyStandaloneServer(ListenUrl, (c) => { if (this.ObjectGraphComposer == null) { throw new Exception("need to setup a composer/scenario for RainyTestServer!"); } this.ObjectGraphComposer(c); }); }
public AppHost(ComposeObjectGraphDelegate graph_composer) : base("Rainy", typeof(GetNotesRequest).Assembly) { this.ComposeObjectGraph = graph_composer; }
public static void Main(string[] args) { // parse command line arguments string config_file = "settings.conf"; string cert_file = null, pvk_file = null; int loglevel = 0; bool show_help = false; bool open_browser = true; var p = new OptionSet() { { "c|config=", "use config file", (string file) => config_file = file }, { "v", "increase log level, where -vvvv is highest", v => { if (v != null) { ++loglevel; } } }, { "h|help", "show this message and exit", v => show_help = v != null }, { "cert=", "use this certificate for SSL", (string file) => cert_file = file }, { "pvk=", "use private key for certSSL", (string file2) => pvk_file = file2 }, { "b|nobrowser", "do not open browser window upon start", v => { if (v != null) { open_browser = false; } } }, }; p.Parse(args); if (show_help) { p.WriteOptionDescriptions(Console.Out); return; } if (!File.Exists(config_file)) { Console.WriteLine("Could not find a configuration file (try the -c flag)!"); return; } // set the configuration from the specified file Config.Global = Config.ApplyJsonFromPath(config_file); DataPath = Config.Global.DataPath; if (string.IsNullOrEmpty(DataPath)) { DataPath = Directory.GetCurrentDirectory(); } else { if (!Directory.Exists(DataPath)) { Directory.CreateDirectory(DataPath); } } SetupLogging(loglevel); logger = LogManager.GetLogger("Main"); string listen_url = Config.Global.ListenUrl; if (string.IsNullOrEmpty(listen_url)) { listen_url = "https://localhost:443/"; logger.InfoFormat("no ListenUrl set in the settings.conf, using the default: {0}", listen_url); } // servicestack expects trailing slash, else error is thrown if (!listen_url.EndsWith("/")) { listen_url += "/"; } ConfigureSslCerts(listen_url, cert_file, pvk_file); // by default we use the filesystem backend if (string.IsNullOrEmpty(Config.Global.Backend)) { Config.Global.Backend = "filesystem"; } if (Config.Global.Backend != "filesystem" && string.IsNullOrEmpty(Config.Global.AdminPassword)) { logger.Fatal("An administrator password must be set"); Environment.Exit(-1); } open_browser = open_browser && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DISPLAY")); open_browser = open_browser && !string.IsNullOrEmpty(Config.Global.AdminPassword); open_browser = open_browser && Config.Global.Backend != "filesystem"; string admin_ui_url = listen_url.Replace("*", "localhost"); admin_ui_url += "admin/"; ComposeObjectGraphDelegate object_graph_composer = ComposeObjectGraph; using (var listener = new RainyStandaloneServer(Config.Global.ListenUrl, object_graph_composer)) { listener.Start(); Uptime = DateTime.UtcNow; if (open_browser) { Process.Start(admin_ui_url); } if (Environment.OSVersion.Platform != PlatformID.Unix && Environment.OSVersion.Platform != PlatformID.MacOSX) { // we run on windows, can't wait for unix signals Console.WriteLine("Press return to stop Rainy"); Console.ReadLine(); Environment.Exit(0); } else { // we run UNIX UnixSignal [] signals = new UnixSignal[] { new UnixSignal(Signum.SIGINT), new UnixSignal(Signum.SIGTERM), }; // Wait for a unix signal for (bool exit = false; !exit;) { int id = UnixSignal.WaitAny(signals); if (id >= 0 && id < signals.Length) { if (signals[id].IsSet) { exit = true; } logger.Debug("received signal, exiting"); } } } } }
public RainyTestServer(ComposeObjectGraphDelegate composer = null) { if (composer == null) { // specifies which default scenario to use this.ScenarioSqlite (); } rainyServer = new RainyStandaloneServer (ListenUrl, (c) => { if (this.ObjectGraphComposer == null) throw new Exception ("need to setup a composer/scenario for RainyTestServer!"); this.ObjectGraphComposer(c); }); }
public void ScenarioSqlite() { this.ObjectGraphComposer = (c) => { this.WireupSqliteTestserver (c); this.WireupGenericTestClasses (c); }; }
public void ScenarioPostgres() { this.ObjectGraphComposer = (c) => { this.WireupPostgresServer (c); this.WireupGenericTestClasses (c); }; }