Skip to content

Instantly share code, notes, and snippets.

@bboyle1234
Created March 12, 2018 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bboyle1234/4ed79eae38b82b8519958cf26fc87f5f to your computer and use it in GitHub Desktop.
Save bboyle1234/4ed79eae38b82b8519958cf26fc87f5f to your computer and use it in GitHub Desktop.
Example MongoDB connection
static ISiloHost CreateSilo() {
var builder = new SiloHostBuilder()
.Configure(options => options.ClusterId = NDGConfig.ClusterId)
.Configure<ProcessExitHandlingOptions>(options => options.FastKillOnProcessExit = false)
.ConfigureSiloName(NDGConfig.ClusterId + "-" + NDGConfig.SiloHostName)
.ConfigureEndpoints(advertisedIP: NDGConfig.SiloIP, siloPort: NDGConfig.SiloPort, gatewayPort: NDGConfig.GatewayPort, listenOnAllHostAddresses: true)
.ConfigureLogging(b => b.SetMinimumLevel(LogLevel.Error).AddConsole())
.UseDashboard(options => {
options.Port = NDGConfig.SiloDashboardPort;
options.Username = NDGConfig.SiloDashboardUsername;
options.Password = NDGConfig.SiloDashboardPassword;
})
.UseMongoDBReminders(options => {
options.ConnectionString = NDGConfig.MongoDBConnectionString;
options.DatabaseName = NDGConfig.ClusterId + "-Reminders";
})
.UseMongoDBClustering(options => {
options.ConnectionString = NDGConfig.MongoDBConnectionString;
options.DatabaseName = NDGConfig.ClusterId + "-Clustering";
});
MongoDBSiloExtensions.AddMongoDBGrainStorageAsDefault(builder, options => {
options.ConnectionString = NDGConfig.MongoDBConnectionString;
options.DatabaseName = NDGConfig.ClusterId + "-Storage";
});
MongoDBSiloExtensions.AddMongoDBGrainStorage(builder, "PubSubStore", options => {
options.ConnectionString = NDGConfig.MongoDBConnectionString;
options.DatabaseName = NDGConfig.ClusterId + "-PubSubStorage";
});
return builder.Build();
}
version: '3'
services:
mysilo:
image: mysilo
links:
- mongo
depends_on:
- mongo
build:
context: .
dockerfile: MySilo/Dockerfile
environment:
- MONGODB_CONNECTION_STRING=mongodb://mongo:27017
mongo-express:
image: mongo-express
hostname: mongo-express
depends_on:
- mongo
links:
- mongo
ports:
- 8081:8081
mongo:
image: mongo
hostname: mongo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment