Skip to content

Commit 3a17a40

Browse files
committed
Remove use_nginx_wrapper option
1 parent 0076796 commit 3a17a40

File tree

3 files changed

+3
-26
lines changed

3 files changed

+3
-26
lines changed

src/bin/server.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate tracing;
55

66
use crates_io::middleware::normalize_path::normalize_path;
77
use crates_io::{metrics::LogEncoder, util::errors::AppResult, App};
8-
use std::{fs::File, process::Command, sync::Arc, time::Duration};
8+
use std::{sync::Arc, time::Duration};
99

1010
use axum::ServiceExt;
1111
use futures_util::future::FutureExt;
@@ -80,21 +80,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
8080
// the test suite :)
8181
info!("Listening at http://{addr}");
8282

83-
// Creating this file tells heroku to tell nginx that the application is ready
84-
// to receive traffic.
85-
if app.config.use_nginx_wrapper {
86-
let path = "/tmp/app-initialized";
87-
info!("Writing to {path}");
88-
File::create(path).unwrap();
89-
90-
// Launch nginx via the Heroku nginx buildpack
91-
// `wait()` is never called on the child process, but it should be okay to leave a zombie
92-
// process around on shutdown when Heroku is tearing down the entire container anyway.
93-
Command::new("./script/start-web.sh")
94-
.spawn()
95-
.expect("Couldn't spawn nginx");
96-
}
97-
9883
// Block the main thread until the server has shutdown
9984
rt.block_on(server)?;
10085

src/config/server.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub struct Server {
2626
pub ip: IpAddr,
2727
pub port: u16,
2828
pub max_blocking_threads: Option<usize>,
29-
pub use_nginx_wrapper: bool,
3029
pub db: DatabasePools,
3130
pub storage: StorageConfig,
3231
pub session_key: cookie::Key,
@@ -105,20 +104,15 @@ impl Default for Server {
105104
/// This function panics if the Server configuration is invalid.
106105
fn default() -> Self {
107106
let docker = dotenvy::var("DEV_DOCKER").is_ok();
108-
109107
let heroku = dotenvy::var("HEROKU").is_ok();
110-
let use_nginx_wrapper = heroku && dotenvy::var("USE_NGINX").unwrap_or_default() != "n";
111108

112-
let ip = if (heroku && !use_nginx_wrapper) || docker {
109+
let ip = if heroku || docker {
113110
[0, 0, 0, 0].into()
114111
} else {
115112
[127, 0, 0, 1].into()
116113
};
117114

118-
let port = match (use_nginx_wrapper, env_optional("PORT")) {
119-
(false, Some(port)) => port,
120-
_ => 8888,
121-
};
115+
let port = env_optional("PORT").unwrap_or(8888);
122116

123117
let allowed_origins = AllowedOrigins::from_default_env();
124118
let page_offset_ua_blocklist = match env_optional::<String>("WEB_PAGE_OFFSET_UA_BLOCKLIST")
@@ -189,7 +183,6 @@ impl Default for Server {
189183
ip,
190184
port,
191185
max_blocking_threads,
192-
use_nginx_wrapper,
193186
session_key: cookie::Key::derive_from(env("SESSION_KEY").as_bytes()),
194187
gh_client_id: ClientId::new(env("GH_CLIENT_ID")),
195188
gh_client_secret: ClientSecret::new(env("GH_CLIENT_SECRET")),

src/tests/util/test_app.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ fn simple_config() -> config::Server {
400400
ip: [127, 0, 0, 1].into(),
401401
port: 8888,
402402
max_blocking_threads: None,
403-
use_nginx_wrapper: false,
404403
db,
405404
storage,
406405
session_key: cookie::Key::derive_from("test this has to be over 32 bytes long".as_bytes()),

0 commit comments

Comments
 (0)