Skip to content

Commit 14786cb

Browse files
committed
#324 #334 optional process management
1 parent ba3ade9 commit 14786cb

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ By far most changes relate to `atomic-server`, so if not specified, assume the c
1313
- Added `data-dir` flag
1414
- Replaced `awc` with `ureq` #374
1515
- Get rid of `.unwrap` calls in `commit_monitor` #345
16+
- Make process management optional #324 #334
1617

1718
## [v0.31.1] - 2022-03-29
1819

server/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ rustls-pemfile = "0.2"
3333
sanitize-filename = "0.3"
3434
serde_json = "1"
3535
static-files = "0.2"
36-
sysinfo = "0.23"
3736
tantivy = "0.17"
3837
tracing = "0.1"
3938
tracing-actix-web = "0.5"
@@ -46,6 +45,10 @@ urlencoding = "2"
4645
optional = true
4746
version = "0.8"
4847

48+
[dependencies.sysinfo]
49+
optional = true
50+
sysinfo = "0.23"
51+
4952
[dependencies.actix-web]
5053
features = ["rustls"]
5154
version = "4.0"
@@ -84,6 +87,7 @@ actix-rt = "2"
8487
[features]
8588
default = ["https"]
8689
https = ["acme-lib", "rustls"]
90+
process-management = ["sysinfo"]
8791

8892
[lib]
8993
name = "atomic_server_lib"

server/src/appstate.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@ pub struct AppState {
2424

2525
/// Creates the AppState (the server's context available in Handlers).
2626
/// Initializes or opens a store on disk.
27-
/// Creates a new agent, if neccessary.
27+
/// Creates a new agent, if necessary.
2828
pub fn init(config: Config) -> AtomicServerResult<AppState> {
2929
tracing::info!("Initializing AppState");
30+
3031
// Check if atomic-server is already running somewhere, and try to stop it. It's not a problem if things go wrong here, so errors are simply logged.
31-
let _ = crate::process::terminate_existing_processes(&config)
32-
.map_err(|e| tracing::error!("Could not check for running instance: {}", e));
32+
if cfg!(feature = "process-management") {
33+
#[cfg(feature = "process-management")]
34+
{
35+
let _ = crate::process::terminate_existing_processes(&config)
36+
.map_err(|e| tracing::error!("Could not check for running instance: {}", e));
37+
}
38+
}
3339

3440
tracing::info!("Opening database at {:?}", &config.store_path);
3541
let store = atomic_lib::Db::init(&config.store_path, config.server_url.clone())?;

server/src/bin.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod helpers;
1212
#[cfg(feature = "https")]
1313
mod https;
1414
mod jsonerrors;
15+
#[cfg(feature = "process-management")]
1516
mod process;
1617
mod routes;
1718
pub mod serve;

server/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ mod helpers;
1414
#[cfg(feature = "https")]
1515
mod https;
1616
mod jsonerrors;
17+
#[cfg(feature = "process-management")]
1718
mod process;
1819
mod routes;
1920
pub mod serve;

server/src/serve.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,14 @@ pub async fn serve(config: crate::config::Config) -> AtomicServerResult<()> {
103103

104104
// Cleanup, runs when server is stopped
105105
tracing_chrome_flush_guard.flush();
106-
crate::process::remove_pid(&config)?;
106+
107+
if cfg!(feature = "process-management") {
108+
#[cfg(feature = "process-management")]
109+
{
110+
crate::process::remove_pid(&config)?;
111+
}
112+
}
113+
107114
tracing::info!("Server stopped");
108115
Ok(())
109116
}

0 commit comments

Comments
 (0)