Skip to content

Commit

Permalink
fix: reenable better stack
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterPtato committed Apr 15, 2024
1 parent ed3bb0e commit d95b07b
Showing 1 changed file with 57 additions and 61 deletions.
118 changes: 57 additions & 61 deletions lib/bolt/core/src/dep/terraform/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,68 +475,64 @@ async fn vars(ctx: &ProjectContext) {
vars.insert("s3_providers".into(), s3_providers(ctx).await.unwrap());
}

// TODO: Reimplement with new server provisioning
// Better Uptime
// if let Some(better_uptime) = &config.better_uptime {
// // Make sure DNS is enabled
// if config.dns.is_none() {
// panic!("Better Uptime requires DNS to be enabled, since it uses subdomains to monitor services");
// }

// // Make sure there is at least one pool
// if config.pools.is_empty() {
// panic!("Better Uptime requires at least one pool, otherwise it will not be able to monitor the service");
// }

// // Load all the regions of pools
// let mut regions = config
// .pools
// .iter()
// .filter_map(|pool| match config.regions.get(&pool.region) {
// Some(region) => Some((pool.region.clone(), region.provider_region.clone())),
// None => None,
// })
// .collect::<HashSet<_>>()
// .into_iter()
// .collect::<Vec<_>>();
// regions.sort();

// // Create monitors
// let mm_monitors = regions
// .iter()
// .map(|(region, _)| {
// json!({
// "id": region,
// "url": format!("{}/status/matchmaker?region={}", ctx.origin_api(), region),
// "public_name": region,
// })
// })
// .collect::<Vec<_>>();

// vars.insert(
// "better_uptime_groups".into(),
// json!([
// {
// "id": "mm",
// "name": "Matchmaker",
// "monitors": mm_monitors,
// },
// {
// "id": "cdn",
// "name": "CDN",
// "monitors": [
// {
// "id": "sandbox",
// "url": format!("https://sandbox.{}", ctx.domain_cdn().unwrap()),
// "public_name": "CDN"
// }
// ]
// },
// ]),
// );

// vars.insert("better_uptime".into(), json!(better_uptime.to_owned()));
// }
if let Some(better_uptime) = &config.better_uptime {
// Make sure DNS is enabled
if config.dns.is_none() {
panic!("Better Uptime requires DNS to be enabled, since it uses subdomains to monitor services");
}

// Make sure there is at least one pool
let Some(cluster) = config
.rivet
.provisioning
.as_ref()
.and_then(|p| p.cluster.as_ref())
else {
panic!("Better Uptime requires cluster provisioning");
};

if cluster.datacenters.is_empty() {
panic!("Better Uptime requires at least one datacenter, otherwise it will not be able to monitor");
};

// Create monitors
let mm_monitors = cluster
.datacenters
.iter()
.map(|(name_id, dc)| {
json!({
"id": dc.datacenter_id,
"url": format!("{}/status/matchmaker?region={}", ctx.origin_api(), name_id),
"public_name": dc.display_name,
})
})
.collect::<Vec<_>>();

vars.insert(
"better_uptime_groups".into(),
json!([
{
"id": "mm",
"name": "Matchmaker",
"monitors": mm_monitors,
},
{
"id": "cdn",
"name": "CDN",
"monitors": [
{
"id": "sandbox",
"url": format!("https://sandbox.{}", ctx.domain_cdn().unwrap()),
"public_name": "CDN"
}
]
},
]),
);

vars.insert("better_uptime".into(), json!(better_uptime.to_owned()));
}

// Media presets
vars.insert(
Expand Down

0 comments on commit d95b07b

Please sign in to comment.