public void Configuration(IAppBuilder app) { log4net.Config.XmlConfigurator.Configure(); var appContext = new ApplicationContext("PushNotifications"); var cfgRepo = new ConsulForPandora(new Uri("http://consul.local.com:8500")); var pandora = new Pandora(appContext, cfgRepo); app.UseHttpWebApi(pandora); }
public static void Start() { try { log.Info("Starting Cronus Push Notifications"); var appContext = new ApplicationContext("PushNotifications"); var cfgRepo = new ConsulForPandora(new Uri("http://consul.local.com:8500")); var pandora = new Pandora(appContext, cfgRepo); container = new Container(); new CronusSettings(container) .UseCluster(cluster => cluster.UseAggregateRootAtomicAction(atomic => { if (pandora.Get<bool>("enable_redis_atomic_action")) atomic.UseRedis(redis => redis.SetLockEndPoints(pandora.Get("redis_endpoints").ParseIPEndPoints(";"))); else atomic.WithInMemory(); })) .UseAppServices(pandora) .UseProjections(pandora) .UsePorts(pandora) .Build(); host = container.Resolve<CronusHost>(); host.Start(); log.Info("STARTED Cronus Push Notifications"); } catch (Exception ex) { log.ErrorException("Unable to boot PushNotifications.WS", ex); throw; } }
public static int Main(string[] args) { string invokedVerb = string.Empty; object invokedVerbInstance = null; var options = new Options(); if (args == null || args.Length == 0) { Console.WriteLine(options.GetUsage()); return 0; } if (!CommandLine.Parser.Default.ParseArguments( args, options, (verb, subOptions) => { invokedVerb = verb; invokedVerbInstance = subOptions; })) { Console.WriteLine(options.GetUsage()); return 0; } if (invokedVerb == "open") { var openOptions = (OpenOptions)invokedVerbInstance; string applicationName = openOptions.Application; string cluster = openOptions.Cluster; string machine = openOptions.Machine; string jarFile = openOptions.Jar ?? openOptions.Application + ".json"; if (!File.Exists(jarFile)) throw new FileNotFoundException("Jar file is required.", jarFile); var jar = JsonConvert.DeserializeObject<Jar>(File.ReadAllText(jarFile)); var box = Box.Box.Mistranslate(jar); if (box.Name != applicationName) throw new InvalidProgramException("Invalid grant"); var cfg = box.Open(new PandoraOptions(cluster, machine)); if (openOptions.Output == OpenOptions.EnvVarOutput) { foreach (var setting in cfg.AsDictionary()) { Environment.SetEnvironmentVariable(setting.Key, setting.Value, EnvironmentVariableTarget.Machine); } } else if (openOptions.Output == OpenOptions.ConsulOutput) { Uri consulAddress = null; if (string.IsNullOrEmpty(openOptions.ConsulHost) == false) consulAddress = new Uri(openOptions.ConsulHost); var consul = new ConsulForPandora(consulAddress); var currentContext = ApplicationConfiguration.CreateContext(applicationName,cluster,machine); var pandora = new Pandora(currentContext, consul); foreach (var setting in pandora.GetAll(currentContext)) { consul.Delete(setting.Raw); } foreach (var setting in cfg.AsDictionary()) { consul.Set(setting.Key, setting.Value); } } else { var computedCfg = JsonConvert.SerializeObject(cfg.AsDictionary()); File.WriteAllText(openOptions.Output, computedCfg); } } return 0; }