summaryrefslogtreecommitdiff
path: root/init/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'init/src/main.rs')
-rw-r--r--init/src/main.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/init/src/main.rs b/init/src/main.rs
index 40e47a4..fa7d086 100644
--- a/init/src/main.rs
+++ b/init/src/main.rs
@@ -4,8 +4,8 @@ mod log;
mod mounts;
mod pid_one;
mod processes;
-mod signals;
mod services;
+mod signals;
use crate::host::locale;
use crate::host::set::set_hostname;
@@ -15,17 +15,19 @@ use crate::mounts::fstab::FstabEntry;
use crate::mounts::rescue;
use crate::pid_one::check_pid;
use crate::processes::udev::spawn_udev;
-use crate::services::unit_parser::Runlevel;
+use crate::services::units::{Runlevel, services_mainloop};
use crate::signals::sigchld;
// RULE: I will not use .expect() and .unwrap() in this project. This causes panic,
// which will affect stability.
-use std::sync::Mutex;
+use std::sync::Mutex;
+use std::thread;
/// Variable which show current runlevel;
-pub static mut RUNLEVEL_STATE: Mutex<Runlevel> = Mutex::new(Runlevel::Undefined);
+pub static RUNLEVEL_STATE: Mutex<Runlevel> = Mutex::new(Runlevel::Undefined);
+// TODO: Add proper RUNLEVEL_STATE switching
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Initializing your system.");
if let Err(e) = check_pid() {
@@ -77,5 +79,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let _ = sigchld::setup_sigchld_handler();
+ thread::spawn(move || services_mainloop());
+
Ok(())
}