Skip to content

Commit 768fcb4

Browse files
authored
Create stream directories on startup (#153)
Create all the temporary directories on program startup. Right now event writer simply creates the record file without checking or creating the directories. This responsibility should be delegated to startup sync where it creates all the directories beforehand based on metadata available. Startup sync now explicitly panics if create temporary directory fails ( permission issues ) or moving some old record file fails. This is because these operations are essential for running the server and it saves users from the confusion of why they cannot post any event. Fixes #74
1 parent 172b295 commit 768fcb4

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

server/src/main.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ include!(concat!(env!("OUT_DIR"), "/generated.rs"));
3636
use std::fs::{self, File};
3737
use std::io::BufReader;
3838
use std::panic::{catch_unwind, AssertUnwindSafe};
39-
use std::path::Path;
4039
use std::thread::{self, JoinHandle};
4140
use std::time::Duration;
4241
use tokio::sync::oneshot;
@@ -109,21 +108,11 @@ async fn main() -> anyhow::Result<()> {
109108
}
110109

111110
fn startup_sync() {
112-
if !Path::new(&CONFIG.parseable.local_disk_path).exists() {
113-
return;
114-
}
115-
116111
for stream in metadata::STREAM_INFO.list_streams() {
117112
let dir = StorageDir::new(stream.clone());
118113

119-
if let Err(e) = dir.create_temp_dir() {
120-
log::error!(
121-
"Error creating tmp directory for {} due to error [{}]",
122-
&stream,
123-
e
124-
);
125-
continue;
126-
}
114+
dir.create_temp_dir()
115+
.expect("Could not create temporary directory. Please check if Parseable is running with correct permissions.");
127116

128117
// if data.records file is not present then skip this stream
129118
if !dir.local_data_exists() {
@@ -162,7 +151,7 @@ fn startup_sync() {
162151
let hostname = utils::hostname_unchecked();
163152
let parquet_file_local = format!("{}{}.data.parquet", local_uri, hostname);
164153
if let Err(err) = dir.move_local_to_temp(parquet_file_local) {
165-
log::warn!(
154+
panic!(
166155
"Failed to move parquet file at {} to tmp directory due to error {}",
167156
path.display(),
168157
err

0 commit comments

Comments
 (0)