diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..0b7df34 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/status-checker.iml b/.idea/status-checker.iml new file mode 100644 index 0000000..cf84ae4 --- /dev/null +++ b/.idea/status-checker.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..80f1b43 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "status-checker" +version = "0.1.0" +edition = "2021" + +[dependencies] +rocket = "0.5.1" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..cbee9d9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,25 @@ +use rocket::http::Status; +use rocket::*; +use std::process::Command; + +#[get("/")] +fn index() -> Status { + let result = Command::new("ping") + .args(["8.8.8.8", "-c", "1", "-W", "1"]) + .status(); + + match result { + Ok(stream) => { + match stream.success() { + true => Status::Ok, + false => Status::InternalServerError, + } + } + Err(_) => Status::InternalServerError, + } +} + +#[launch] +fn rocket() -> _ { + build().mount("/", routes![index]) +}