single-user service manager
0

Configure Feed

Select the types of activity you want to include in your feed.

rename to moxservice!

r0chd (Apr 8, 2026, 5:57 PM +0200) 630d88e4 cb6fde32

+317 -285
+3 -3
.forgejo/workflows/push-to-cachix.yaml
··· 29 29 run: nix-env -iA cachix -f https://cachix.org/api/v1/install 30 30 31 31 - name: Setup Cachix 32 - run: cachix authtoken "${{ secrets.CACHIX_SIGNING_KEY }}" && cachix use moxsm 32 + run: cachix authtoken "${{ secrets.CACHIX_SIGNING_KEY }}" && cachix use moxservice 33 33 34 34 - name: Build and push to Cachix 35 35 run: | 36 - nix build --no-link --print-out-paths | cachix push moxsm 36 + nix build --no-link --print-out-paths | cachix push moxservice 37 37 38 38 - name: Trigger mox-flake update via API 39 39 run: | ··· 42 42 -H "Authorization: token ${{ secrets.REPO_TOKEN }}" \ 43 43 -H "Accept: application/json" \ 44 44 -H "Content-Type: application/json" \ 45 - -d '{"ref":"master", "inputs": {"project":"moxsm"}}' 45 + -d '{"ref":"master", "inputs": {"project":"moxservice"}}'
+1 -1
Cargo.toml
··· 22 22 23 23 [workspace.package] 24 24 license = "GPLv3" 25 - repository = "https://github.com/mox-desktop/moxsm" 25 + repository = "https://github.com/mox-desktop/moxservice" 26 26 version = "0.1.0"
-10
a.nix
··· 1 - { 2 - name = "imperative"; 3 - description = "imperative service"; 4 - exec = "/usr/bin/env tail -f /dev/null"; 5 - env = { }; 6 - restart = { 7 - on = "failure"; 8 - sec = "5"; 9 - }; 10 - }
+1 -1
common/build.rs
··· 3 3 .type_attribute(".", "#[derive(serde::Deserialize)]") 4 4 .type_attribute(".", "#[derive(serde::Serialize)]") 5 5 .type_attribute(".", "#[serde(rename_all = \"camelCase\")]") 6 - .compile(&["../protocols/moxsm_service_registration_v1.xml"]) 6 + .compile(&["../protocols/moxservice_service_registration_v1.xml"]) 7 7 .unwrap(); 8 8 }
+3 -3
common/src/lib.rs
··· 1 - pub mod moxsm_service_registration_v1 { 2 - hyprwire::include_protocol!("moxsm_service_registration_v1"); 1 + pub mod moxservice_service_registration_v1 { 2 + hyprwire::include_protocol!("moxservice_service_registration_v1"); 3 3 pub use spec::*; 4 4 } 5 5 ··· 13 13 pub use closure::{BuildMetadata, ClosureService, ClosureServices}; 14 14 pub use command::parse_command_line; 15 15 pub use graph::Graph; 16 - pub use moxsm_service_registration_v1::{RestartOn, ServiceType}; 16 + pub use moxservice_service_registration_v1::{RestartOn, ServiceType}; 17 17 pub use resources::{CpuLimit, High, Limits, Max, MemoryLimit, Resources}; 18 18 pub use restart::{Restart, RestartSec}; 19 19 pub use service::{ServiceConfig, ServiceDependencies};
+3 -3
common/src/restart.rs
··· 1 1 use serde::de::{Error, Visitor}; 2 2 use serde::{Deserialize, Serialize}; 3 3 4 - use crate::moxsm_service_registration_v1; 4 + use crate::moxservice_service_registration_v1; 5 5 6 6 #[derive(Debug, Clone, Copy, PartialEq, Eq)] 7 7 pub struct RestartSec(pub u64); ··· 80 80 } 81 81 82 82 #[allow(clippy::derivable_impls)] 83 - impl Default for moxsm_service_registration_v1::RestartOn { 83 + impl Default for moxservice_service_registration_v1::RestartOn { 84 84 fn default() -> Self { 85 85 Self::No 86 86 } ··· 90 90 #[serde(rename_all = "camelCase")] 91 91 pub struct Restart { 92 92 #[serde(default)] 93 - pub on: moxsm_service_registration_v1::RestartOn, 93 + pub on: moxservice_service_registration_v1::RestartOn, 94 94 #[serde(default)] 95 95 pub sec: RestartSec, 96 96 }
+5 -5
common/src/service.rs
··· 1 1 use crate::command::parse_command_line; 2 - use crate::moxsm_service_registration_v1; 2 + use crate::moxservice_service_registration_v1; 3 3 use crate::resources::Resources; 4 4 use crate::restart::Restart; 5 5 use nix::unistd; ··· 8 8 use std::{fs, path, rc}; 9 9 10 10 #[allow(clippy::derivable_impls)] 11 - impl Default for moxsm_service_registration_v1::ServiceType { 11 + impl Default for moxservice_service_registration_v1::ServiceType { 12 12 fn default() -> Self { 13 13 Self::Simple 14 14 } ··· 32 32 #[serde(default)] 33 33 pub dependencies: ServiceDependencies, 34 34 #[serde(rename = "type", default = "default_service_type")] 35 - pub r#type: moxsm_service_registration_v1::ServiceType, 35 + pub r#type: moxservice_service_registration_v1::ServiceType, 36 36 #[serde(default)] 37 37 pub resources: Resources, 38 38 #[serde(default)] ··· 88 88 .unwrap_or_else(|| gid.as_raw().to_string()) 89 89 } 90 90 91 - fn default_service_type() -> moxsm_service_registration_v1::ServiceType { 92 - moxsm_service_registration_v1::ServiceType::Simple 91 + fn default_service_type() -> moxservice_service_registration_v1::ServiceType { 92 + moxservice_service_registration_v1::ServiceType::Simple 93 93 }
+1 -1
ctl/build.rs
··· 1 1 fn main() { 2 2 hyprwire_scanner::configure() 3 - .compile(&["../protocols/moxsm_core_v1.xml"]) 3 + .compile(&["../protocols/moxservice_core_v1.xml"]) 4 4 .unwrap(); 5 5 }
+73 -65
ctl/src/main.rs
··· 1 - mod moxsm_core_v1 { 2 - hyprwire::include_protocol!("moxsm_core_v1"); 1 + mod moxservice_core_v1 { 2 + hyprwire::include_protocol!("moxservice_core_v1"); 3 3 pub use client::*; 4 4 pub use spec::*; 5 5 } ··· 7 7 mod switch; 8 8 9 9 use clap::{Parser, Subcommand}; 10 - use common::moxsm_service_registration_v1; 10 + use common::moxservice_service_registration_v1; 11 11 use hyprwire::client; 12 12 use hyprwire::implementation::client::ProtocolImplementations; 13 13 use nix::unistd; ··· 20 20 #[derive(Debug)] 21 21 struct ServiceRow { 22 22 pid: u32, 23 - status: moxsm_core_v1::ServiceStatus, 23 + status: moxservice_core_v1::ServiceStatus, 24 24 description: String, 25 - object: Option<moxsm_core_v1::MoxsmCoreServiceObject>, 25 + object: Option<moxservice_core_v1::MoxserviceCoreServiceObject>, 26 26 started_at: u32, 27 27 path: Option<String>, 28 28 command: Option<String>, ··· 37 37 fn default() -> Self { 38 38 Self { 39 39 pid: 0, 40 - status: moxsm_core_v1::ServiceStatus::Dead, 40 + status: moxservice_core_v1::ServiceStatus::Dead, 41 41 description: String::new(), 42 42 object: None, 43 43 started_at: 0, ··· 55 55 struct ServiceListRow { 56 56 pid: String, 57 57 name: String, 58 - status: moxsm_core_v1::ServiceStatus, 58 + status: moxservice_core_v1::ServiceStatus, 59 59 uptime: String, 60 60 description: String, 61 61 } ··· 71 71 struct ImperativeService { 72 72 name: String, 73 73 id: Option<u32>, 74 - object: moxsm_service_registration_v1::client::MoxsmServiceObject, 74 + object: moxservice_service_registration_v1::client::MoxserviceServiceObject, 75 75 done: bool, 76 76 } 77 77 78 78 impl 79 - hyprwire::Dispatch<moxsm_service_registration_v1::client::MoxsmServiceRegistrationManagerObject> 80 - for App 79 + hyprwire::Dispatch< 80 + moxservice_service_registration_v1::client::MoxserviceServiceRegistrationManagerObject, 81 + > for App 81 82 { 82 83 fn event( 83 84 &mut self, 84 - _object: &moxsm_service_registration_v1::client::MoxsmServiceRegistrationManagerObject, 85 - event: <moxsm_service_registration_v1::client::MoxsmServiceRegistrationManagerObject as hyprwire::Object>::Event<'_>, 85 + _object: &moxservice_service_registration_v1::client::MoxserviceServiceRegistrationManagerObject, 86 + event: <moxservice_service_registration_v1::client::MoxserviceServiceRegistrationManagerObject as hyprwire::Object>::Event<'_>, 86 87 ) { 87 88 match event { 88 - moxsm_service_registration_v1::client::MoxsmServiceRegistrationManagerEvent::ServiceCreated { name, id } => { 89 + moxservice_service_registration_v1::client::MoxserviceServiceRegistrationManagerEvent::ServiceCreated { name, id } => { 89 90 if let Some(service) = self.imperative_service.as_mut() { 90 91 service.name = name.clone(); 91 92 service.id = Some(id); ··· 95 96 ">".green().bold() 96 97 ); 97 98 } 98 - moxsm_service_registration_v1::client::MoxsmServiceRegistrationManagerEvent::ServiceRemoved { id } => { 99 + moxservice_service_registration_v1::client::MoxserviceServiceRegistrationManagerEvent::ServiceRemoved { id } => { 99 100 if let Some(service) = self.imperative_service.as_mut() 100 101 && service.id == Some(id) 101 102 { ··· 103 104 } 104 105 println!("{} service id {id} removed", ">".yellow().bold()); 105 106 } 106 - moxsm_service_registration_v1::client::MoxsmServiceRegistrationManagerEvent::Error { message } => { 107 + moxservice_service_registration_v1::client::MoxserviceServiceRegistrationManagerEvent::Error { message } => { 107 108 if let Some(service) = self.imperative_service.as_mut() { 108 109 service.done = true; 109 110 } ··· 113 114 } 114 115 } 115 116 116 - impl hyprwire::Dispatch<moxsm_service_registration_v1::client::MoxsmServiceObject> for App { 117 + impl hyprwire::Dispatch<moxservice_service_registration_v1::client::MoxserviceServiceObject> 118 + for App 119 + { 117 120 fn event( 118 121 &mut self, 119 - object: &moxsm_service_registration_v1::client::MoxsmServiceObject, 120 - event: <moxsm_service_registration_v1::client::MoxsmServiceObject as hyprwire::Object>::Event<'_>, 122 + object: &moxservice_service_registration_v1::client::MoxserviceServiceObject, 123 + event: <moxservice_service_registration_v1::client::MoxserviceServiceObject as hyprwire::Object>::Event<'_>, 121 124 ) { 122 125 let Some(service) = self.imperative_service.as_mut() else { 123 126 return; ··· 127 130 } 128 131 129 132 match event { 130 - moxsm_service_registration_v1::client::MoxsmServiceEvent::Running { 133 + moxservice_service_registration_v1::client::MoxserviceServiceEvent::Running { 131 134 pid, 132 135 timestamp, 133 136 } => { ··· 137 140 service.name 138 141 ); 139 142 } 140 - moxsm_service_registration_v1::client::MoxsmServiceEvent::Failed { 143 + moxservice_service_registration_v1::client::MoxserviceServiceEvent::Failed { 141 144 message, 142 145 timestamp, 143 146 } => { ··· 148 151 .bold() 149 152 ); 150 153 } 151 - moxsm_service_registration_v1::client::MoxsmServiceEvent::Exited { 154 + moxservice_service_registration_v1::client::MoxserviceServiceEvent::Exited { 152 155 status, 153 156 timestamp, 154 157 } => { ··· 158 161 service.name 159 162 ); 160 163 } 161 - moxsm_service_registration_v1::client::MoxsmServiceEvent::LogPath { stream, path } => { 164 + moxservice_service_registration_v1::client::MoxserviceServiceEvent::LogPath { 165 + stream, 166 + path, 167 + } => { 162 168 println!( 163 169 "{} {} {stream} log: {path}", 164 170 ">".blue().bold(), ··· 169 175 } 170 176 } 171 177 172 - impl hyprwire::Dispatch<moxsm_core_v1::MoxsmCoreManagerObject> for App { 178 + impl hyprwire::Dispatch<moxservice_core_v1::MoxserviceCoreManagerObject> for App { 173 179 fn event( 174 180 &mut self, 175 - _object: &moxsm_core_v1::MoxsmCoreManagerObject, 176 - event: <moxsm_core_v1::MoxsmCoreManagerObject as hyprwire::Object>::Event<'_>, 181 + _object: &moxservice_core_v1::MoxserviceCoreManagerObject, 182 + event: <moxservice_core_v1::MoxserviceCoreManagerObject as hyprwire::Object>::Event<'_>, 177 183 ) { 178 184 match event { 179 - moxsm_core_v1::MoxsmCoreManagerEvent::Service { 185 + moxservice_core_v1::MoxserviceCoreManagerEvent::Service { 180 186 pid, 181 187 name, 182 188 status, ··· 191 197 row.object = None; 192 198 row.restarts = None; 193 199 } 194 - moxsm_core_v1::MoxsmCoreManagerEvent::ServiceRemoved { name } => { 200 + moxservice_core_v1::MoxserviceCoreManagerEvent::ServiceRemoved { name } => { 195 201 self.services.remove(&name); 196 202 } 197 - moxsm_core_v1::MoxsmCoreManagerEvent::ReloadSuccess => { 203 + moxservice_core_v1::MoxserviceCoreManagerEvent::ReloadSuccess => { 198 204 self.reload_result = Some(Ok(())); 199 205 } 200 - moxsm_core_v1::MoxsmCoreManagerEvent::ReloadError { message } => { 206 + moxservice_core_v1::MoxserviceCoreManagerEvent::ReloadError { message } => { 201 207 self.reload_result = Some(Err(message)); 202 208 } 203 - moxsm_core_v1::MoxsmCoreManagerEvent::Done => { 209 + moxservice_core_v1::MoxserviceCoreManagerEvent::Done => { 204 210 self.manager_batch_done = true; 205 211 } 206 212 } 207 213 } 208 214 } 209 215 210 - impl hyprwire::Dispatch<moxsm_core_v1::MoxsmCoreServiceObject> for App { 216 + impl hyprwire::Dispatch<moxservice_core_v1::MoxserviceCoreServiceObject> for App { 211 217 fn event( 212 218 &mut self, 213 - object: &moxsm_core_v1::MoxsmCoreServiceObject, 214 - event: <moxsm_core_v1::MoxsmCoreServiceObject as hyprwire::Object>::Event<'_>, 219 + object: &moxservice_core_v1::MoxserviceCoreServiceObject, 220 + event: <moxservice_core_v1::MoxserviceCoreServiceObject as hyprwire::Object>::Event<'_>, 215 221 ) { 216 222 let Some(service) = self.services.values_mut().find(|service| { 217 223 service ··· 223 229 }; 224 230 225 231 match event { 226 - moxsm_core_v1::MoxsmCoreServiceEvent::Status { status } => { 232 + moxservice_core_v1::MoxserviceCoreServiceEvent::Status { status } => { 227 233 service.status = status; 228 234 } 229 - moxsm_core_v1::MoxsmCoreServiceEvent::Name { name: _ } => {} 230 - moxsm_core_v1::MoxsmCoreServiceEvent::Description { description } => { 235 + moxservice_core_v1::MoxserviceCoreServiceEvent::Name { name: _ } => {} 236 + moxservice_core_v1::MoxserviceCoreServiceEvent::Description { description } => { 231 237 service.description = description; 232 238 } 233 - moxsm_core_v1::MoxsmCoreServiceEvent::Path { path } => { 239 + moxservice_core_v1::MoxserviceCoreServiceEvent::Path { path } => { 234 240 service.path = Some(path); 235 241 } 236 - moxsm_core_v1::MoxsmCoreServiceEvent::Command { command } => { 242 + moxservice_core_v1::MoxserviceCoreServiceEvent::Command { command } => { 237 243 service.command = Some(command); 238 244 } 239 - moxsm_core_v1::MoxsmCoreServiceEvent::Pid { pid } => { 245 + moxservice_core_v1::MoxserviceCoreServiceEvent::Pid { pid } => { 240 246 service.pid = pid; 241 247 } 242 - moxsm_core_v1::MoxsmCoreServiceEvent::User { user } => { 248 + moxservice_core_v1::MoxserviceCoreServiceEvent::User { user } => { 243 249 service.user = Some(user); 244 250 } 245 - moxsm_core_v1::MoxsmCoreServiceEvent::Group { group } => { 251 + moxservice_core_v1::MoxserviceCoreServiceEvent::Group { group } => { 246 252 service.group = Some(group); 247 253 } 248 - moxsm_core_v1::MoxsmCoreServiceEvent::StdoutPath { path } => { 254 + moxservice_core_v1::MoxserviceCoreServiceEvent::StdoutPath { path } => { 249 255 service.stdout_path = Some(path); 250 256 } 251 - moxsm_core_v1::MoxsmCoreServiceEvent::StderrPath { path } => { 257 + moxservice_core_v1::MoxserviceCoreServiceEvent::StderrPath { path } => { 252 258 service.stderr_path = Some(path); 253 259 } 254 - moxsm_core_v1::MoxsmCoreServiceEvent::StartedAt { started_at } => { 260 + moxservice_core_v1::MoxserviceCoreServiceEvent::StartedAt { started_at } => { 255 261 service.started_at = started_at; 256 262 } 257 - moxsm_core_v1::MoxsmCoreServiceEvent::Restarts { restarts } => { 263 + moxservice_core_v1::MoxserviceCoreServiceEvent::Restarts { restarts } => { 258 264 service.restarts = Some(restarts); 259 265 } 260 - moxsm_core_v1::MoxsmCoreServiceEvent::Removed => {} 261 - moxsm_core_v1::MoxsmCoreServiceEvent::Done => {} 266 + moxservice_core_v1::MoxserviceCoreServiceEvent::Removed => {} 267 + moxservice_core_v1::MoxserviceCoreServiceEvent::Done => {} 262 268 } 263 269 } 264 270 } ··· 296 302 #[arg( 297 303 short, 298 304 long, 299 - env = "MOXSM_SERVICE_DIR", 305 + env = "MOXSERVICE_SERVICE_DIR", 300 306 value_name = "DIR", 301 307 help = "Path to the service directory" 302 308 )] ··· 309 315 310 316 let socket_path = if cli.user { 311 317 dirs::runtime_dir() 312 - .map(|dir| dir.join("mox").join("moxsm.sock")) 318 + .map(|dir| dir.join("mox").join("moxservice.sock")) 313 319 .ok_or_else(|| anyhow::anyhow!("failed to resolve runtime directory"))? 314 320 } else { 315 - path::PathBuf::from("/run/mox/moxsm.sock") 321 + path::PathBuf::from("/run/mox/moxservice.sock") 316 322 }; 317 323 318 324 if let Command::Switch { service_dir } = cli.command { ··· 320 326 } 321 327 322 328 let mut socket = client::Client::open(socket_path)?; 323 - let implementation = moxsm_core_v1::MoxsmCoreV1Impl::default(); 329 + let implementation = moxservice_core_v1::MoxserviceCoreV1Impl::default(); 324 330 let registration_implementation = 325 - moxsm_service_registration_v1::client::MoxsmServiceRegistrationV1Impl::default(); 331 + moxservice_service_registration_v1::client::MoxserviceServiceRegistrationV1Impl::default(); 326 332 socket.add_implementation(implementation.clone()); 327 333 socket.add_implementation(registration_implementation.clone()); 328 334 socket.wait_for_handshake()?; 329 335 330 - let manager = 331 - socket.bind::<moxsm_core_v1::MoxsmCoreManagerObject, App>(implementation.protocol(), 1)?; 336 + let manager = socket.bind::<moxservice_core_v1::MoxserviceCoreManagerObject, App>( 337 + implementation.protocol(), 338 + 1, 339 + )?; 332 340 333 341 let mut app = App::default(); 334 342 while !app.manager_batch_done { ··· 538 546 let config = common::ServiceConfig::load(path.clone())?; 539 547 540 548 let manager = socket 541 - .bind::<moxsm_service_registration_v1::client::MoxsmServiceRegistrationManagerObject, App>( 549 + .bind::<moxservice_service_registration_v1::client::MoxserviceServiceRegistrationManagerObject, App>( 542 550 registration_implementation.protocol(), 543 551 1, 544 552 )?; ··· 612 620 } 613 621 } 614 622 615 - fn format_status(status: moxsm_core_v1::ServiceStatus) -> &'static str { 623 + fn format_status(status: moxservice_core_v1::ServiceStatus) -> &'static str { 616 624 match status { 617 - moxsm_core_v1::ServiceStatus::Running => "running", 618 - moxsm_core_v1::ServiceStatus::Dead => "dead", 619 - moxsm_core_v1::ServiceStatus::Failed => "failed", 625 + moxservice_core_v1::ServiceStatus::Running => "running", 626 + moxservice_core_v1::ServiceStatus::Dead => "dead", 627 + moxservice_core_v1::ServiceStatus::Failed => "failed", 620 628 } 621 629 } 622 630 623 - fn style_status(status: moxsm_core_v1::ServiceStatus) -> String { 631 + fn style_status(status: moxservice_core_v1::ServiceStatus) -> String { 624 632 colorize_status(format_status(status).to_string()) 625 633 } 626 634 ··· 663 671 664 672 for service in services.values() { 665 673 match service.status { 666 - moxsm_core_v1::ServiceStatus::Running => running += 1, 667 - moxsm_core_v1::ServiceStatus::Dead => dead += 1, 668 - moxsm_core_v1::ServiceStatus::Failed => failed += 1, 674 + moxservice_core_v1::ServiceStatus::Running => running += 1, 675 + moxservice_core_v1::ServiceStatus::Dead => dead += 1, 676 + moxservice_core_v1::ServiceStatus::Failed => failed += 1, 669 677 } 670 678 } 671 679 ··· 719 727 fn service_cgroup_path(user: bool, name: &str) -> path::PathBuf { 720 728 if user { 721 729 path::PathBuf::from(format!( 722 - "/sys/fs/cgroup/moxsm/users/uid-{}/services/{name}", 730 + "/sys/fs/cgroup/moxservice/users/uid-{}/services/{name}", 723 731 unistd::getuid() 724 732 )) 725 733 } else { 726 - path::PathBuf::from(format!("/sys/fs/cgroup/moxsm/services/{name}")) 734 + path::PathBuf::from(format!("/sys/fs/cgroup/moxservice/services/{name}")) 727 735 } 728 736 } 729 737
+19 -17
ctl/src/switch.rs
··· 1 - use crate::moxsm_core_v1; 1 + use crate::moxservice_core_v1; 2 2 use common::Graph; 3 3 use hyprwire::client; 4 4 use hyprwire::implementation::client::ProtocolImplementations; ··· 12 12 reload_result: Option<Result<(), String>>, 13 13 } 14 14 15 - impl hyprwire::Dispatch<moxsm_core_v1::MoxsmCoreManagerObject> for ReloadApp { 15 + impl hyprwire::Dispatch<moxservice_core_v1::MoxserviceCoreManagerObject> for ReloadApp { 16 16 fn event( 17 17 &mut self, 18 - _object: &moxsm_core_v1::MoxsmCoreManagerObject, 19 - event: <moxsm_core_v1::MoxsmCoreManagerObject as hyprwire::Object>::Event<'_>, 18 + _object: &moxservice_core_v1::MoxserviceCoreManagerObject, 19 + event: <moxservice_core_v1::MoxserviceCoreManagerObject as hyprwire::Object>::Event<'_>, 20 20 ) { 21 21 match event { 22 - moxsm_core_v1::MoxsmCoreManagerEvent::ReloadSuccess => { 22 + moxservice_core_v1::MoxserviceCoreManagerEvent::ReloadSuccess => { 23 23 self.reload_result = Some(Ok(())); 24 24 } 25 - moxsm_core_v1::MoxsmCoreManagerEvent::ReloadError { message } => { 25 + moxservice_core_v1::MoxserviceCoreManagerEvent::ReloadError { message } => { 26 26 self.reload_result = Some(Err(message)); 27 27 } 28 - moxsm_core_v1::MoxsmCoreManagerEvent::Done => {} 29 - moxsm_core_v1::MoxsmCoreManagerEvent::Service { .. } 30 - | moxsm_core_v1::MoxsmCoreManagerEvent::ServiceRemoved { .. } => {} 28 + moxservice_core_v1::MoxserviceCoreManagerEvent::Done => {} 29 + moxservice_core_v1::MoxserviceCoreManagerEvent::Service { .. } 30 + | moxservice_core_v1::MoxserviceCoreManagerEvent::ServiceRemoved { .. } => {} 31 31 } 32 32 } 33 33 } ··· 40 40 let Some(name) = entry.file_name().to_str().map(str::to_owned) else { 41 41 continue; 42 42 }; 43 - let Some(number) = name.strip_prefix("moxsm-") else { 43 + let Some(number) = name.strip_prefix("moxservice-") else { 44 44 continue; 45 45 }; 46 46 let Ok(number) = number.parse::<u32>() else { ··· 55 55 fn generations_dir(user: bool) -> anyhow::Result<path::PathBuf> { 56 56 if user { 57 57 dirs::state_dir() 58 - .map(|dir| dir.join("moxsm").join("generations")) 58 + .map(|dir| dir.join("moxservice").join("generations")) 59 59 .ok_or_else(|| anyhow::anyhow!("failed to resolve state directory")) 60 60 } else { 61 - Ok(path::PathBuf::from("/var/lib/moxsm/generations")) 61 + Ok(path::PathBuf::from("/var/lib/moxservice/generations")) 62 62 } 63 63 } 64 64 65 65 fn current_link(user: bool) -> anyhow::Result<path::PathBuf> { 66 - Ok(generations_dir(user)?.join("moxsm")) 66 + Ok(generations_dir(user)?.join("moxservice")) 67 67 } 68 68 69 69 fn build(service_dir: path::PathBuf) -> anyhow::Result<path::PathBuf> { ··· 228 228 } else { 229 229 fs::create_dir_all(&generations_dir)?; 230 230 let generation_id = next_generation_id(&generations_dir)?; 231 - let generation_path = generations_dir.join(format!("moxsm-{generation_id}")); 231 + let generation_path = generations_dir.join(format!("moxservice-{generation_id}")); 232 232 fs::rename(&path, &generation_path)?; 233 233 234 234 let mut metadata = common::BuildMetadata::load(&generation_path.join("metadata.json"))?; ··· 259 259 println!("{} Activating configuration", ">".blue().bold()); 260 260 261 261 let mut socket = client::Client::open(socket_path)?; 262 - let implementation = moxsm_core_v1::MoxsmCoreV1Impl::default(); 262 + let implementation = moxservice_core_v1::MoxserviceCoreV1Impl::default(); 263 263 socket.add_implementation(implementation.clone()); 264 264 socket.wait_for_handshake()?; 265 265 266 - let manager = socket 267 - .bind::<moxsm_core_v1::MoxsmCoreManagerObject, ReloadApp>(implementation.protocol(), 1)?; 266 + let manager = socket.bind::<moxservice_core_v1::MoxserviceCoreManagerObject, ReloadApp>( 267 + implementation.protocol(), 268 + 1, 269 + )?; 268 270 let mut app = ReloadApp::default(); 269 271 socket.roundtrip(&mut app)?; 270 272 manager.send_reload();
+2 -2
daemon/build.rs
··· 1 1 fn main() { 2 2 hyprwire_scanner::configure() 3 3 .compile(&[ 4 - "../protocols/moxsm_core_v1.xml", 5 - "../protocols/moxsm_user_v1.xml", 4 + "../protocols/moxservice_core_v1.xml", 5 + "../protocols/moxservice_user_v1.xml", 6 6 ]) 7 7 .unwrap(); 8 8 }
+35 -24
daemon/src/cgroup/mod.rs
··· 1 - use crate::Moxsm; 2 - use crate::{moxsm_user_v1, service}; 1 + use crate::Moxservice; 2 + use crate::{moxservice_user_v1, service}; 3 3 use anyhow::Context; 4 4 use calloop::generic; 5 5 use hyprwire::implementation::client::ProtocolImplementations; ··· 26 26 27 27 pub struct UserState { 28 28 cgroup_path: Option<path::PathBuf>, 29 - _manager: moxsm_user_v1::client::MoxsmUserManagerObject, 29 + _manager: moxservice_user_v1::client::MoxserviceUserManagerObject, 30 30 } 31 31 32 32 pub struct CgroupManager<M> { ··· 108 108 109 109 impl CgroupManager<SystemState> { 110 110 pub fn new() -> anyhow::Result<Self> { 111 - let cgroup_path = path::PathBuf::from("/sys/fs/cgroup/moxsm"); 111 + let cgroup_path = path::PathBuf::from("/sys/fs/cgroup/moxservice"); 112 112 fs::create_dir_all(cgroup_path.join("users"))?; 113 113 fs::create_dir_all(cgroup_path.join("manager"))?; 114 114 fs::create_dir_all(cgroup_path.join("services"))?; ··· 138 138 139 139 let uid = unistd::Uid::from_raw(uid); 140 140 let user = unistd::User::from_uid(uid)?.unwrap(); 141 - let path = path::PathBuf::from(format!("/sys/fs/cgroup/moxsm/users/uid-{}", { 141 + let path = path::PathBuf::from(format!("/sys/fs/cgroup/moxservice/users/uid-{}", { 142 142 uid.as_raw() 143 143 })); 144 144 let manager_path = path.join("manager"); ··· 181 181 .position(|user| user.client == client) 182 182 { 183 183 let user = self.state.users.swap_remove(index); 184 - fs::remove_dir_all(format!("/sys/fs/cgroup/moxsm/users/uid-{}", user.user.uid))?; 184 + fs::remove_dir_all(format!( 185 + "/sys/fs/cgroup/moxservice/users/uid-{}", 186 + user.user.uid 187 + ))?; 185 188 } 186 189 187 190 Ok(()) ··· 283 286 pub fn stop_service( 284 287 &mut self, 285 288 service: &dyn service::Service<T>, 286 - loop_handle: calloop::LoopHandle<'static, Moxsm<T>>, 289 + loop_handle: calloop::LoopHandle<'static, Moxservice<T>>, 287 290 ) -> anyhow::Result<()> { 288 291 if let Some(index) = self 289 292 .services ··· 369 372 impl CgroupManager<UserState> { 370 373 pub fn new<D>() -> anyhow::Result<(Self, client::Client)> 371 374 where 372 - D: hyprwire::Dispatch<moxsm_user_v1::client::MoxsmUserManagerObject>, 375 + D: hyprwire::Dispatch<moxservice_user_v1::client::MoxserviceUserManagerObject>, 373 376 { 374 - let mut socket = client::Client::open("/run/mox/moxsm.sock")?; 375 - let implementation = moxsm_user_v1::client::MoxsmUserV1Impl::default(); 377 + let mut socket = client::Client::open("/run/mox/moxservice.sock")?; 378 + let implementation = moxservice_user_v1::client::MoxserviceUserV1Impl::default(); 376 379 socket.add_implementation(implementation.clone()); 377 380 socket.wait_for_handshake()?; 378 381 379 - let manager = socket.bind::<moxsm_user_v1::client::MoxsmUserManagerObject, D>( 382 + let manager = socket.bind::<moxservice_user_v1::client::MoxserviceUserManagerObject, D>( 380 383 implementation.protocol(), 381 384 1, 382 385 )?; ··· 395 398 } 396 399 } 397 400 398 - impl moxsm_user_v1::server::MoxsmUserV1Handler for Moxsm<SystemState> { 399 - fn bind(&mut self, _object: moxsm_user_v1::server::MoxsmUserManagerObject) {} 401 + impl moxservice_user_v1::server::MoxserviceUserV1Handler for Moxservice<SystemState> { 402 + fn bind(&mut self, _object: moxservice_user_v1::server::MoxserviceUserManagerObject) {} 400 403 } 401 404 402 - impl hyprwire::Dispatch<moxsm_user_v1::server::MoxsmUserManagerObject> for Moxsm<SystemState> { 405 + impl hyprwire::Dispatch<moxservice_user_v1::server::MoxserviceUserManagerObject> 406 + for Moxservice<SystemState> 407 + { 403 408 fn event( 404 409 &mut self, 405 - object: &moxsm_user_v1::server::MoxsmUserManagerObject, 406 - event: <moxsm_user_v1::server::MoxsmUserManagerObject as hyprwire::Object>::Event<'_>, 410 + object: &moxservice_user_v1::server::MoxserviceUserManagerObject, 411 + event: <moxservice_user_v1::server::MoxserviceUserManagerObject as hyprwire::Object>::Event< 412 + '_, 413 + >, 407 414 ) { 408 415 match event { 409 - moxsm_user_v1::server::MoxsmUserManagerEvent::Register => { 416 + moxservice_user_v1::server::MoxserviceUserManagerEvent::Register => { 410 417 if self 411 418 .cgroup 412 419 .state ··· 416 423 .is_some() 417 424 { 418 425 object.error( 419 - moxsm_user_v1::UserManagerError::DuplicateRegistration as u32, 426 + moxservice_user_v1::UserManagerError::DuplicateRegistration as u32, 420 427 "duplicate user-manager registration for this client is not allowed", 421 428 ); 422 429 return; ··· 432 439 } 433 440 } 434 441 } 435 - moxsm_user_v1::server::MoxsmUserManagerEvent::Destroy => { 442 + moxservice_user_v1::server::MoxserviceUserManagerEvent::Destroy => { 436 443 if let Some(client) = object.client() { 437 444 _ = self.cgroup.remove_user(client); 438 445 } ··· 441 448 } 442 449 } 443 450 444 - impl hyprwire::Dispatch<moxsm_user_v1::client::MoxsmUserManagerObject> for Moxsm<UserState> { 451 + impl hyprwire::Dispatch<moxservice_user_v1::client::MoxserviceUserManagerObject> 452 + for Moxservice<UserState> 453 + { 445 454 fn event( 446 455 &mut self, 447 - _object: &moxsm_user_v1::client::MoxsmUserManagerObject, 448 - event: <moxsm_user_v1::client::MoxsmUserManagerObject as hyprwire::Object>::Event<'_>, 456 + _object: &moxservice_user_v1::client::MoxserviceUserManagerObject, 457 + event: <moxservice_user_v1::client::MoxserviceUserManagerObject as hyprwire::Object>::Event< 458 + '_, 459 + >, 449 460 ) { 450 461 match event { 451 - moxsm_user_v1::client::MoxsmUserManagerEvent::Registered { 462 + moxservice_user_v1::client::MoxserviceUserManagerEvent::Registered { 452 463 uid: _uid, 453 464 cgroup_path, 454 465 } => { ··· 462 473 log::error!("failed to enable user service cgroup controllers: {err:#}"); 463 474 } 464 475 } 465 - moxsm_user_v1::client::MoxsmUserManagerEvent::Error { message } => { 476 + moxservice_user_v1::client::MoxserviceUserManagerEvent::Error { message } => { 466 477 log::error!("Failed to register user service manager: {message}"); 467 478 } 468 479 }
+70 -51
daemon/src/main.rs
··· 1 - mod moxsm_core_v1 { 2 - hyprwire::include_protocol!("moxsm_core_v1"); 1 + mod moxservice_core_v1 { 2 + hyprwire::include_protocol!("moxservice_core_v1"); 3 3 pub use server::*; 4 4 pub use spec::*; 5 5 } 6 - mod moxsm_user_v1 { 7 - hyprwire::include_protocol!("moxsm_user_v1"); 6 + mod moxservice_user_v1 { 7 + hyprwire::include_protocol!("moxservice_user_v1"); 8 8 pub use spec::*; 9 9 } 10 10 ··· 13 13 14 14 use calloop::generic; 15 15 use common::Graph; 16 - use common::moxsm_service_registration_v1; 16 + use common::moxservice_service_registration_v1; 17 17 use hyprwire::server; 18 18 use nix::unistd; 19 19 use service::imperative; ··· 25 25 use crate::service::oneshot; 26 26 use crate::service::simple; 27 27 28 - pub struct Moxsm<M> { 28 + pub struct Moxservice<M> { 29 29 pub active_config_path: path::PathBuf, 30 30 pub log_dir: rc::Rc<path::Path>, 31 31 pub services: Vec<Box<dyn service::Service<M>>>, 32 32 pub imperative_services: Vec<imperative::Imperative>, 33 - managers: Vec<moxsm_core_v1::MoxsmCoreManagerObject>, 33 + managers: Vec<moxservice_core_v1::MoxserviceCoreManagerObject>, 34 34 loop_handle: calloop::LoopHandle<'static, Self>, 35 35 cgroup: cgroup::CgroupManager<M>, 36 36 } 37 37 38 - impl<M: cgroup::CgroupState + 'static> Moxsm<M> { 39 - fn send_manager_snapshot(&self, manager: &moxsm_core_v1::MoxsmCoreManagerObject) { 38 + impl<M: cgroup::CgroupState + 'static> Moxservice<M> { 39 + fn send_manager_snapshot(&self, manager: &moxservice_core_v1::MoxserviceCoreManagerObject) { 40 40 for service in &self.services { 41 41 manager.send_service( 42 42 service.process().map(|child| child.id()).unwrap_or(0), ··· 286 286 } 287 287 } 288 288 289 - impl<M> Drop for Moxsm<M> { 289 + impl<M> Drop for Moxservice<M> { 290 290 fn drop(&mut self) { 291 291 self.cgroup.kill_services(); 292 292 } 293 293 } 294 294 295 - impl<M: cgroup::CgroupState + 'static> moxsm_core_v1::MoxsmCoreV1Handler for Moxsm<M> { 296 - fn bind(&mut self, object: moxsm_core_v1::MoxsmCoreManagerObject) { 295 + impl<M: cgroup::CgroupState + 'static> moxservice_core_v1::MoxserviceCoreV1Handler 296 + for Moxservice<M> 297 + { 298 + fn bind(&mut self, object: moxservice_core_v1::MoxserviceCoreManagerObject) { 297 299 self.managers.push(object.clone()); 298 300 self.loop_handle.insert_idle(move |state| { 299 301 state.send_manager_snapshot(&object); ··· 301 303 } 302 304 } 303 305 304 - impl<M: cgroup::CgroupState + 'static> hyprwire::Dispatch<moxsm_core_v1::MoxsmCoreManagerObject> 305 - for Moxsm<M> 306 + impl<M: cgroup::CgroupState + 'static> 307 + hyprwire::Dispatch<moxservice_core_v1::MoxserviceCoreManagerObject> for Moxservice<M> 306 308 { 307 309 fn event( 308 310 &mut self, 309 - object: &moxsm_core_v1::MoxsmCoreManagerObject, 310 - event: <moxsm_core_v1::MoxsmCoreManagerObject as hyprwire::Object>::Event<'_>, 311 + object: &moxservice_core_v1::MoxserviceCoreManagerObject, 312 + event: <moxservice_core_v1::MoxserviceCoreManagerObject as hyprwire::Object>::Event<'_>, 311 313 ) { 312 314 match event { 313 - moxsm_core_v1::MoxsmCoreManagerEvent::GetService { seq, name } => { 315 + moxservice_core_v1::MoxserviceCoreManagerEvent::GetService { seq, name } => { 314 316 if let Some(index) = self 315 317 .services 316 318 .iter() ··· 350 352 } 351 353 } 352 354 } 353 - moxsm_core_v1::MoxsmCoreManagerEvent::Destroy => { 355 + moxservice_core_v1::MoxserviceCoreManagerEvent::Destroy => { 354 356 self.managers.retain(|manager| manager != object); 355 357 } 356 - moxsm_core_v1::MoxsmCoreManagerEvent::Reload => { 358 + moxservice_core_v1::MoxserviceCoreManagerEvent::Reload => { 357 359 match self.reload_active_config() { 358 360 Ok(()) => object.send_reload_success(), 359 361 Err(err) => object.send_reload_error(err.to_string()), ··· 364 366 } 365 367 } 366 368 367 - impl<M: cgroup::CgroupState + 'static> hyprwire::Dispatch<moxsm_core_v1::MoxsmCoreServiceObject> 368 - for Moxsm<M> 369 + impl<M: cgroup::CgroupState + 'static> 370 + hyprwire::Dispatch<moxservice_core_v1::MoxserviceCoreServiceObject> for Moxservice<M> 369 371 { 370 372 fn event( 371 373 &mut self, 372 - object: &moxsm_core_v1::MoxsmCoreServiceObject, 373 - event: <moxsm_core_v1::MoxsmCoreServiceObject as hyprwire::Object>::Event<'_>, 374 + object: &moxservice_core_v1::MoxserviceCoreServiceObject, 375 + event: <moxservice_core_v1::MoxserviceCoreServiceObject as hyprwire::Object>::Event<'_>, 374 376 ) { 375 377 if let Some(index) = self.services.iter().position(|service| { 376 378 service ··· 379 381 .any(|service_object| service_object == object) 380 382 }) { 381 383 match event { 382 - moxsm_core_v1::MoxsmCoreServiceEvent::Start => { 384 + moxservice_core_v1::MoxserviceCoreServiceEvent::Start => { 383 385 match self 384 386 .cgroup 385 387 .open_service_procs(self.services[index].as_ref()) ··· 401 403 log::error!("{err}"); 402 404 } 403 405 } 404 - moxsm_core_v1::MoxsmCoreServiceEvent::Stop => { 406 + moxservice_core_v1::MoxserviceCoreServiceEvent::Stop => { 405 407 if let Err(e) = self 406 408 .cgroup 407 409 .stop_service(&*self.services[index], self.loop_handle.clone()) ··· 416 418 self.services[index].stop(); 417 419 self.broadcast_service(self.services[index].as_ref()); 418 420 } 419 - moxsm_core_v1::MoxsmCoreServiceEvent::Restart => { 421 + moxservice_core_v1::MoxserviceCoreServiceEvent::Restart => { 420 422 match self 421 423 .cgroup 422 424 .open_service_procs(self.services[index].as_ref()) ··· 438 440 log::error!("{err}"); 439 441 } 440 442 } 441 - moxsm_core_v1::MoxsmCoreServiceEvent::Destroy => { 443 + moxservice_core_v1::MoxserviceCoreServiceEvent::Destroy => { 442 444 self.services[index] 443 445 .objects_mut() 444 446 .retain(|service_object| service_object != object); ··· 465 467 let uid = unistd::getuid(); 466 468 467 469 let active_path = if uid.is_root() { 468 - path::PathBuf::from("/var/lib/moxsm/generations/moxsm") 470 + path::PathBuf::from("/var/lib/moxservice/generations/moxservice") 469 471 } else { 470 472 dirs::state_dir() 471 - .map(|dir| dir.join("moxsm").join("generations").join("moxsm")) 473 + .map(|dir| { 474 + dir.join("moxservice") 475 + .join("generations") 476 + .join("moxservice") 477 + }) 472 478 .ok_or_else(|| anyhow::anyhow!("failed to resolve state directory"))? 473 479 }; 474 480 if let Some(parent) = active_path.parent() { ··· 476 482 } 477 483 478 484 let socket_path = if uid.is_root() { 479 - path::PathBuf::from("/run/mox/moxsm.sock") 485 + path::PathBuf::from("/run/mox/moxservice.sock") 480 486 } else { 481 487 dirs::runtime_dir() 482 - .map(|dir| dir.join("mox").join("moxsm.sock")) 488 + .map(|dir| dir.join("mox").join("moxservice.sock")) 483 489 .ok_or_else(|| anyhow::anyhow!("failed to resolve runtime directory"))? 484 490 }; 485 491 if let Some(parent) = socket_path.parent() { 486 492 _ = fs::create_dir_all(parent); 487 493 } 488 494 489 - _ = fs::create_dir_all("/sys/fs/cgroup/moxsm"); 495 + _ = fs::create_dir_all("/sys/fs/cgroup/moxservice"); 490 496 491 497 let log_dir = if uid.is_root() { 492 - path::PathBuf::from("/var/log/moxsm") 498 + path::PathBuf::from("/var/log/moxservice") 493 499 } else { 494 500 dirs::state_dir() 495 - .map(|dir| dir.join("moxsm").join("logs")) 501 + .map(|dir| dir.join("moxservice").join("logs")) 496 502 .ok_or_else(|| anyhow::anyhow!("failed to resolve state directory"))? 497 503 }; 498 504 ··· 503 509 cgroup.enable_memory_controller()?; 504 510 cgroup.enable_pids_controller()?; 505 511 cgroup.enable_io_controller()?; 506 - let mut moxsm = Moxsm::new(active_path, log_dir.clone(), event_loop.handle(), cgroup)?; 507 - if moxsm.active_config_path.exists() 508 - && let Err(err) = moxsm.reload_active_config() 512 + let mut moxservice = 513 + Moxservice::new(active_path, log_dir.clone(), event_loop.handle(), cgroup)?; 514 + if moxservice.active_config_path.exists() 515 + && let Err(err) = moxservice.reload_active_config() 509 516 { 510 517 log::error!("{err}"); 511 518 } 512 519 513 520 let mut socket = server::Server::open(Some(&socket_path))?; 514 521 fs::set_permissions(&socket_path, fs::Permissions::from_mode(0o666))?; 515 - socket.add_implementation(moxsm_core_v1::MoxsmCoreV1Impl::new(1, &mut moxsm)); 516 - socket.add_implementation(moxsm_user_v1::server::MoxsmUserV1Impl::new(1, &mut moxsm)); 522 + socket.add_implementation(moxservice_core_v1::MoxserviceCoreV1Impl::new( 523 + 1, 524 + &mut moxservice, 525 + )); 526 + socket.add_implementation(moxservice_user_v1::server::MoxserviceUserV1Impl::new( 527 + 1, 528 + &mut moxservice, 529 + )); 517 530 socket.add_implementation( 518 - moxsm_service_registration_v1::server::MoxsmServiceRegistrationV1Impl::new( 519 - 1, &mut moxsm, 531 + moxservice_service_registration_v1::server::MoxserviceServiceRegistrationV1Impl::new( 532 + 1, 533 + &mut moxservice, 520 534 ), 521 535 ); 522 536 ··· 537 551 Ok(calloop::PostAction::Continue) 538 552 })?; 539 553 540 - event_loop.run(None, &mut moxsm, move |_| {})?; 554 + event_loop.run(None, &mut moxservice, move |_| {})?; 541 555 } else { 542 556 let mut event_loop = calloop::EventLoop::try_new()?; 543 557 let (cgroup, registration_socket) = 544 - cgroup::CgroupManager::<cgroup::UserState>::new::<Moxsm<cgroup::UserState>>()?; 545 - let mut moxsm = Moxsm::new(active_path, log_dir.clone(), event_loop.handle(), cgroup)?; 546 - registration_socket.roundtrip(&mut moxsm)?; 547 - if moxsm.active_config_path.exists() 548 - && let Err(err) = moxsm.reload_active_config() 558 + cgroup::CgroupManager::<cgroup::UserState>::new::<Moxservice<cgroup::UserState>>()?; 559 + let mut moxservice = 560 + Moxservice::new(active_path, log_dir.clone(), event_loop.handle(), cgroup)?; 561 + registration_socket.roundtrip(&mut moxservice)?; 562 + if moxservice.active_config_path.exists() 563 + && let Err(err) = moxservice.reload_active_config() 549 564 { 550 565 log::error!("{err}"); 551 566 } 552 567 553 568 let mut socket = server::Server::open(Some(&socket_path))?; 554 - socket.add_implementation(moxsm_core_v1::MoxsmCoreV1Impl::new(1, &mut moxsm)); 569 + socket.add_implementation(moxservice_core_v1::MoxserviceCoreV1Impl::new( 570 + 1, 571 + &mut moxservice, 572 + )); 555 573 socket.add_implementation( 556 - moxsm_service_registration_v1::server::MoxsmServiceRegistrationV1Impl::new( 557 - 1, &mut moxsm, 574 + moxservice_service_registration_v1::server::MoxserviceServiceRegistrationV1Impl::new( 575 + 1, 576 + &mut moxservice, 558 577 ), 559 578 ); 560 579 ··· 593 612 Ok(calloop::PostAction::Continue) 594 613 })?; 595 614 596 - event_loop.run(None, &mut moxsm, move |_| {})?; 615 + event_loop.run(None, &mut moxservice, move |_| {})?; 597 616 } 598 617 599 618 Ok(())
+35 -33
daemon/src/service/imperative.rs
··· 1 1 /// This is not a service trait implementation, this is essentially a wrapper for service 2 2 /// for services created imperatively through hyprwire protocol instead of declaratively 3 - use crate::moxsm_service_registration_v1; 3 + use crate::moxservice_service_registration_v1; 4 4 use crate::service::{oneshot, simple}; 5 5 use crate::{cgroup, service}; 6 6 use std::{mem, path, rc}; 7 7 8 8 pub struct Imperative { 9 9 path: Option<path::PathBuf>, 10 - object: moxsm_service_registration_v1::server::MoxsmServiceObject, 10 + object: moxservice_service_registration_v1::server::MoxserviceServiceObject, 11 11 service_name: rc::Rc<str>, 12 12 config: common::ServiceConfig, 13 13 configured: bool, 14 14 } 15 15 16 16 impl<M: cgroup::CgroupState + 'static> 17 - hyprwire::Dispatch<moxsm_service_registration_v1::server::MoxsmServiceRegistrationManagerObject> 18 - for crate::Moxsm<M> 17 + hyprwire::Dispatch< 18 + moxservice_service_registration_v1::server::MoxserviceServiceRegistrationManagerObject, 19 + > for crate::Moxservice<M> 19 20 { 20 21 fn event( 21 22 &mut self, 22 - object: &moxsm_service_registration_v1::server::MoxsmServiceRegistrationManagerObject, 23 - event: <moxsm_service_registration_v1::server::MoxsmServiceRegistrationManagerObject as hyprwire::Object>::Event<'_>, 23 + object: &moxservice_service_registration_v1::server::MoxserviceServiceRegistrationManagerObject, 24 + event: <moxservice_service_registration_v1::server::MoxserviceServiceRegistrationManagerObject as hyprwire::Object>::Event<'_>, 24 25 ) { 25 26 match event { 26 - moxsm_service_registration_v1::server::MoxsmServiceRegistrationManagerEvent::CreateService { seq, name } => { 27 + moxservice_service_registration_v1::server::MoxserviceServiceRegistrationManagerEvent::CreateService { seq, name } => { 27 28 if let Some(object) = object.create_service::<Self>(seq) { 28 29 let service_name: rc::Rc<str> = name.into(); 29 30 let config = common::ServiceConfig { ··· 41 42 object.send_error("Failed to create imperative service object"); 42 43 } 43 44 } 44 - moxsm_service_registration_v1::server::MoxsmServiceRegistrationManagerEvent::Destroy => {} 45 + moxservice_service_registration_v1::server::MoxserviceServiceRegistrationManagerEvent::Destroy => {} 45 46 } 46 47 } 47 48 } 48 49 49 50 impl<M: cgroup::CgroupState + 'static> 50 - hyprwire::Dispatch<moxsm_service_registration_v1::server::MoxsmServiceObject> 51 - for crate::Moxsm<M> 51 + hyprwire::Dispatch<moxservice_service_registration_v1::server::MoxserviceServiceObject> 52 + for crate::Moxservice<M> 52 53 { 53 54 fn event( 54 55 &mut self, 55 - object: &moxsm_service_registration_v1::server::MoxsmServiceObject, 56 - event: <moxsm_service_registration_v1::server::MoxsmServiceObject as hyprwire::Object>::Event<'_>, 56 + object: &moxservice_service_registration_v1::server::MoxserviceServiceObject, 57 + event: <moxservice_service_registration_v1::server::MoxserviceServiceObject as hyprwire::Object>::Event<'_>, 57 58 ) { 58 59 let Some(service_index) = self 59 60 .imperative_services ··· 65 66 66 67 let is_destroy = matches!( 67 68 &event, 68 - moxsm_service_registration_v1::server::MoxsmServiceEvent::Destroy 69 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::Destroy 69 70 ); 70 71 if self.imperative_services[service_index].configured && !is_destroy { 71 72 object.error( 72 - moxsm_service_registration_v1::ServiceError::AlreadyConfigured as u32, 73 + moxservice_service_registration_v1::ServiceError::AlreadyConfigured as u32, 73 74 "trying to modify configured service", 74 75 ); 75 76 return; 76 77 } 77 78 78 79 match event { 79 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetDescription { 80 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetDescription { 80 81 description, 81 82 } => { 82 83 self.imperative_services[service_index].config.description = description; 83 84 } 84 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetType { r#type } => { 85 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetType { r#type } => { 85 86 self.imperative_services[service_index].config.r#type = r#type; 86 87 } 87 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetExec { command } => { 88 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetExec { command } => { 88 89 self.imperative_services[service_index].config.exec = command; 89 90 } 90 - moxsm_service_registration_v1::server::MoxsmServiceEvent::AddEnv { key, value } => { 91 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::AddEnv { key, value } => { 91 92 self.imperative_services[service_index] 92 93 .config 93 94 .env 94 95 .insert(key, value); 95 96 } 96 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetUser { user } => { 97 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetUser { user } => { 97 98 self.imperative_services[service_index].config.user = user; 98 99 } 99 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetGroup { group } => { 100 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetGroup { group } => { 100 101 self.imperative_services[service_index].config.group = group; 101 102 } 102 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetStdoutPath { path } => { 103 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetStdoutPath { path } => { 103 104 self.imperative_services[service_index].config.stdout_path = Some(path.into()); 104 105 } 105 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetStderrPath { path } => { 106 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetStderrPath { path } => { 106 107 self.imperative_services[service_index].config.stderr_path = Some(path.into()); 107 108 } 108 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetPath { path } => { 109 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetPath { path } => { 109 110 self.imperative_services[service_index].path = Some(path.into()); 110 111 } 111 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetRestartPolicy { 112 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetRestartPolicy { 112 113 on, 113 114 sec, 114 115 } => { ··· 117 118 sec: common::RestartSec(sec as u64), 118 119 } 119 120 } 120 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetMemoryLimit { value } => { 121 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetMemoryLimit { value } => { 121 122 match parse_max_u64(&value) { 122 123 Ok(memory) => { 123 124 self.imperative_services[service_index] ··· 129 130 Err(err) => object.send_failed(err.to_string(), 0), 130 131 } 131 132 } 132 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetMemoryHigh { value } => { 133 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetMemoryHigh { value } => { 133 134 match parse_max_u64(&value) { 134 135 Ok(memory) => { 135 136 self.imperative_services[service_index] ··· 141 142 Err(err) => object.send_failed(err.to_string(), 0), 142 143 } 143 144 } 144 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetCpuLimit { value } => { 145 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetCpuLimit { value } => { 145 146 match parse_cpu_limit(&value) { 146 147 Ok(cpu) => { 147 148 self.imperative_services[service_index] ··· 153 154 Err(err) => object.send_failed(err.to_string(), 0), 154 155 } 155 156 } 156 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetPidsLimit { value } => { 157 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetPidsLimit { value } => { 157 158 match parse_max_u64(&value) { 158 159 Ok(pids) => { 159 160 self.imperative_services[service_index] ··· 165 166 Err(err) => object.send_failed(err.to_string(), 0), 166 167 } 167 168 } 168 - moxsm_service_registration_v1::server::MoxsmServiceEvent::SetIoLimit { value } => { 169 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::SetIoLimit { value } => { 169 170 self.imperative_services[service_index] 170 171 .config 171 172 .resources 172 173 .limits 173 174 .io = Some(value); 174 175 } 175 - moxsm_service_registration_v1::server::MoxsmServiceEvent::Configure => { 176 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::Configure => { 176 177 self.imperative_services[service_index].configured = true; 177 178 178 179 let config = mem::take(&mut self.imperative_services[service_index].config); ··· 197 198 object.send_failed(err.to_string(), 0); 198 199 } 199 200 } 200 - moxsm_service_registration_v1::server::MoxsmServiceEvent::Destroy => { 201 + moxservice_service_registration_v1::server::MoxserviceServiceEvent::Destroy => { 201 202 let service_name = 202 203 rc::Rc::clone(&self.imperative_services[service_index].service_name); 203 204 self.imperative_services.swap_remove(service_index); ··· 227 228 } 228 229 229 230 impl<M: cgroup::CgroupState + 'static> 230 - moxsm_service_registration_v1::server::MoxsmServiceRegistrationV1Handler for crate::Moxsm<M> 231 + moxservice_service_registration_v1::server::MoxserviceServiceRegistrationV1Handler 232 + for crate::Moxservice<M> 231 233 { 232 234 fn bind( 233 235 &mut self, 234 - _object: moxsm_service_registration_v1::server::MoxsmServiceRegistrationManagerObject, 236 + _object: moxservice_service_registration_v1::server::MoxserviceServiceRegistrationManagerObject, 235 237 ) { 236 238 } 237 239 }
+6 -6
daemon/src/service/mod.rs
··· 2 2 pub mod oneshot; 3 3 pub mod simple; 4 4 5 - use crate::moxsm_core_v1; 5 + use crate::moxservice_core_v1; 6 6 use std::{any, fs, path, process, rc}; 7 7 8 8 pub trait Service<M: crate::cgroup::CgroupState + 'static>: any::Any { ··· 10 10 11 11 fn path(&self) -> Option<&path::Path>; 12 12 13 - fn objects(&self) -> &[moxsm_core_v1::MoxsmCoreServiceObject]; 13 + fn objects(&self) -> &[moxservice_core_v1::MoxserviceCoreServiceObject]; 14 14 15 - fn objects_mut(&mut self) -> &mut Vec<moxsm_core_v1::MoxsmCoreServiceObject>; 15 + fn objects_mut(&mut self) -> &mut Vec<moxservice_core_v1::MoxserviceCoreServiceObject>; 16 16 17 17 fn process(&self) -> Option<&process::Child>; 18 18 19 - fn status(&self) -> moxsm_core_v1::ServiceStatus; 19 + fn status(&self) -> moxservice_core_v1::ServiceStatus; 20 20 21 21 fn started_at(&self) -> u32; 22 22 ··· 30 30 31 31 fn start( 32 32 &mut self, 33 - handle: calloop::LoopHandle<'static, crate::Moxsm<M>>, 33 + handle: calloop::LoopHandle<'static, crate::Moxservice<M>>, 34 34 log_dir: rc::Rc<path::Path>, 35 35 cgroup_procs: fs::File, 36 36 ) -> anyhow::Result<()>; ··· 39 39 40 40 fn restart( 41 41 &mut self, 42 - handle: calloop::LoopHandle<'static, crate::Moxsm<M>>, 42 + handle: calloop::LoopHandle<'static, crate::Moxservice<M>>, 43 43 log_dir: rc::Rc<path::Path>, 44 44 cgroup_procs: fs::File, 45 45 ) -> anyhow::Result<()> {
+21 -21
daemon/src/service/oneshot.rs
··· 1 1 use super::Service; 2 - use crate::moxsm_core_v1; 2 + use crate::moxservice_core_v1; 3 3 use calloop::{generic, timer}; 4 4 use nix::unistd; 5 5 use std::os::unix::process::CommandExt; ··· 9 9 pub struct Oneshot { 10 10 pub config: common::ServiceConfig, 11 11 pub path: Option<path::PathBuf>, 12 - pub objects: Vec<moxsm_core_v1::MoxsmCoreServiceObject>, 12 + pub objects: Vec<moxservice_core_v1::MoxserviceCoreServiceObject>, 13 13 pub process: Option<process::Child>, 14 - pub status: moxsm_core_v1::ServiceStatus, 14 + pub status: moxservice_core_v1::ServiceStatus, 15 15 pub started_at: u32, 16 16 pub restarts: u32, 17 17 pub pending_start: bool, ··· 30 30 path, 31 31 objects: Vec::new(), 32 32 process: None, 33 - status: moxsm_core_v1::ServiceStatus::Dead, 33 + status: moxservice_core_v1::ServiceStatus::Dead, 34 34 started_at: 0, 35 35 pending_start: true, 36 36 children_ready: false, ··· 47 47 self.path.as_deref() 48 48 } 49 49 50 - fn objects(&self) -> &[moxsm_core_v1::MoxsmCoreServiceObject] { 50 + fn objects(&self) -> &[moxservice_core_v1::MoxserviceCoreServiceObject] { 51 51 &self.objects 52 52 } 53 53 54 - fn objects_mut(&mut self) -> &mut Vec<moxsm_core_v1::MoxsmCoreServiceObject> { 54 + fn objects_mut(&mut self) -> &mut Vec<moxservice_core_v1::MoxserviceCoreServiceObject> { 55 55 &mut self.objects 56 56 } 57 57 ··· 59 59 self.process.as_ref() 60 60 } 61 61 62 - fn status(&self) -> moxsm_core_v1::ServiceStatus { 62 + fn status(&self) -> moxservice_core_v1::ServiceStatus { 63 63 self.status 64 64 } 65 65 ··· 77 77 78 78 fn start( 79 79 &mut self, 80 - handle: calloop::LoopHandle<'static, crate::Moxsm<M>>, 80 + handle: calloop::LoopHandle<'static, crate::Moxservice<M>>, 81 81 log_dir: rc::Rc<path::Path>, 82 82 cgroup_procs: fs::File, 83 83 ) -> anyhow::Result<()> { ··· 104 104 let uid = match unistd::User::from_name(&self.config.user) { 105 105 Ok(Some(user)) => user.uid.as_raw(), 106 106 Ok(None) => { 107 - self.status = moxsm_core_v1::ServiceStatus::Failed; 107 + self.status = moxservice_core_v1::ServiceStatus::Failed; 108 108 return Err(anyhow::anyhow!( 109 109 "failed to start service {}: user {} not found", 110 110 self.config.name, ··· 112 112 )); 113 113 } 114 114 Err(e) => { 115 - self.status = moxsm_core_v1::ServiceStatus::Failed; 115 + self.status = moxservice_core_v1::ServiceStatus::Failed; 116 116 return Err(anyhow::anyhow!( 117 117 "failed to start service {}: failed to resolve user {}: {e}", 118 118 self.config.name, ··· 123 123 let gid = match unistd::Group::from_name(&self.config.group) { 124 124 Ok(Some(group)) => group.gid.as_raw(), 125 125 Ok(None) => { 126 - self.status = moxsm_core_v1::ServiceStatus::Failed; 126 + self.status = moxservice_core_v1::ServiceStatus::Failed; 127 127 return Err(anyhow::anyhow!( 128 128 "failed to start service {}: group {} not found", 129 129 self.config.name, ··· 131 131 )); 132 132 } 133 133 Err(e) => { 134 - self.status = moxsm_core_v1::ServiceStatus::Failed; 134 + self.status = moxservice_core_v1::ServiceStatus::Failed; 135 135 return Err(anyhow::anyhow!( 136 136 "failed to start service {}: failed to resolve group {}: {e}", 137 137 self.config.name, ··· 177 177 calloop::Mode::Level, 178 178 ); 179 179 180 - handle.insert_source(source, move |_, _, state: &mut crate::Moxsm<M>| { 180 + handle.insert_source(source, move |_, _, state: &mut crate::Moxservice<M>| { 181 181 let Some(index) = state 182 182 .services 183 183 .iter() ··· 201 201 should_restart = 202 202 service.config.restart.on == common::RestartOn::Always; 203 203 204 - service.status = moxsm_core_v1::ServiceStatus::Dead 204 + service.status = moxservice_core_v1::ServiceStatus::Dead 205 205 } else { 206 206 should_restart = service.config.restart.on 207 207 == common::RestartOn::Failure 208 208 || service.config.restart.on == common::RestartOn::Always; 209 209 210 - service.status = moxsm_core_v1::ServiceStatus::Failed 210 + service.status = moxservice_core_v1::ServiceStatus::Failed 211 211 } 212 212 service.pending_start = false; 213 213 service.children_ready = status.success(); ··· 228 228 service.config.name 229 229 ); 230 230 service.process = None; 231 - service.status = moxsm_core_v1::ServiceStatus::Failed; 231 + service.status = moxservice_core_v1::ServiceStatus::Failed; 232 232 service.pending_start = false; 233 233 service.children_ready = false; 234 234 service.started_at = 0; ··· 251 251 let restart_delay = state.services[index].config().restart.sec.as_millis(); 252 252 if let Err(err) = handle.insert_source( 253 253 timer::Timer::from_duration(time::Duration::from_millis(restart_delay)), 254 - move |_, _, state: &mut crate::Moxsm<M>| { 254 + move |_, _, state: &mut crate::Moxservice<M>| { 255 255 let log_dir = rc::Rc::clone(&state.log_dir); 256 256 let Some(service) = state.services.get_mut(index) else { 257 257 return timer::TimeoutAction::Drop; ··· 288 288 })?; 289 289 290 290 self.process = Some(process); 291 - self.status = moxsm_core_v1::ServiceStatus::Running; 291 + self.status = moxservice_core_v1::ServiceStatus::Running; 292 292 self.started_at = since_epoch.as_secs() as u32; 293 293 log::info!("started service {}", self.config.name); 294 294 Ok(()) 295 295 } 296 296 Err(e) => { 297 - self.status = moxsm_core_v1::ServiceStatus::Failed; 297 + self.status = moxservice_core_v1::ServiceStatus::Failed; 298 298 Err(anyhow::anyhow!( 299 299 "failed to start service {}: {e}", 300 300 self.config.name ··· 310 310 } 311 311 312 312 self.started_at = 0; 313 - self.status = moxsm_core_v1::ServiceStatus::Dead; 313 + self.status = moxservice_core_v1::ServiceStatus::Dead; 314 314 self.children_ready = false; 315 315 log::info!("stopped service {}", self.config.name); 316 316 } 317 317 318 318 fn restart( 319 319 &mut self, 320 - handle: calloop::LoopHandle<'static, crate::Moxsm<M>>, 320 + handle: calloop::LoopHandle<'static, crate::Moxservice<M>>, 321 321 log_dir: rc::Rc<path::Path>, 322 322 cgroup_procs: fs::File, 323 323 ) -> anyhow::Result<()> {
+21 -21
daemon/src/service/simple.rs
··· 1 1 use super::Service; 2 - use crate::moxsm_core_v1; 2 + use crate::moxservice_core_v1; 3 3 use calloop::{generic, timer}; 4 4 use nix::unistd; 5 5 use std::os::unix::process::CommandExt; ··· 9 9 pub struct Simple { 10 10 pub config: common::ServiceConfig, 11 11 pub path: Option<path::PathBuf>, 12 - pub objects: Vec<moxsm_core_v1::MoxsmCoreServiceObject>, 12 + pub objects: Vec<moxservice_core_v1::MoxserviceCoreServiceObject>, 13 13 pub process: Option<process::Child>, 14 - pub status: moxsm_core_v1::ServiceStatus, 14 + pub status: moxservice_core_v1::ServiceStatus, 15 15 pub started_at: u32, 16 16 pub restarts: u32, 17 17 pub pending_start: bool, ··· 30 30 path, 31 31 objects: Vec::new(), 32 32 process: None, 33 - status: moxsm_core_v1::ServiceStatus::Dead, 33 + status: moxservice_core_v1::ServiceStatus::Dead, 34 34 started_at: 0, 35 35 pending_start: true, 36 36 children_ready: false, ··· 47 47 self.path.as_deref() 48 48 } 49 49 50 - fn objects(&self) -> &[moxsm_core_v1::MoxsmCoreServiceObject] { 50 + fn objects(&self) -> &[moxservice_core_v1::MoxserviceCoreServiceObject] { 51 51 &self.objects 52 52 } 53 53 54 - fn objects_mut(&mut self) -> &mut Vec<moxsm_core_v1::MoxsmCoreServiceObject> { 54 + fn objects_mut(&mut self) -> &mut Vec<moxservice_core_v1::MoxserviceCoreServiceObject> { 55 55 &mut self.objects 56 56 } 57 57 ··· 63 63 self.process.as_ref() 64 64 } 65 65 66 - fn status(&self) -> moxsm_core_v1::ServiceStatus { 66 + fn status(&self) -> moxservice_core_v1::ServiceStatus { 67 67 self.status 68 68 } 69 69 ··· 81 81 82 82 fn start( 83 83 &mut self, 84 - handle: calloop::LoopHandle<'static, crate::Moxsm<M>>, 84 + handle: calloop::LoopHandle<'static, crate::Moxservice<M>>, 85 85 log_dir: rc::Rc<path::Path>, 86 86 cgroup_procs: fs::File, 87 87 ) -> anyhow::Result<()> { ··· 108 108 let uid = match unistd::User::from_name(&self.config.user) { 109 109 Ok(Some(user)) => user.uid.as_raw(), 110 110 Ok(None) => { 111 - self.status = moxsm_core_v1::ServiceStatus::Failed; 111 + self.status = moxservice_core_v1::ServiceStatus::Failed; 112 112 return Err(anyhow::anyhow!( 113 113 "failed to start service {}: user {} not found", 114 114 self.config.name, ··· 116 116 )); 117 117 } 118 118 Err(e) => { 119 - self.status = moxsm_core_v1::ServiceStatus::Failed; 119 + self.status = moxservice_core_v1::ServiceStatus::Failed; 120 120 return Err(anyhow::anyhow!( 121 121 "failed to start service {}: failed to resolve user {}: {e}", 122 122 self.config.name, ··· 127 127 let gid = match unistd::Group::from_name(&self.config.group) { 128 128 Ok(Some(group)) => group.gid.as_raw(), 129 129 Ok(None) => { 130 - self.status = moxsm_core_v1::ServiceStatus::Failed; 130 + self.status = moxservice_core_v1::ServiceStatus::Failed; 131 131 return Err(anyhow::anyhow!( 132 132 "failed to start service {}: group {} not found", 133 133 self.config.name, ··· 135 135 )); 136 136 } 137 137 Err(e) => { 138 - self.status = moxsm_core_v1::ServiceStatus::Failed; 138 + self.status = moxservice_core_v1::ServiceStatus::Failed; 139 139 return Err(anyhow::anyhow!( 140 140 "failed to start service {}: failed to resolve group {}: {e}", 141 141 self.config.name, ··· 180 180 calloop::Mode::Level, 181 181 ); 182 182 183 - handle.insert_source(source, move |_, _, state: &mut crate::Moxsm<M>| { 183 + handle.insert_source(source, move |_, _, state: &mut crate::Moxservice<M>| { 184 184 let Some(index) = state 185 185 .services 186 186 .iter() ··· 204 204 should_restart = 205 205 service.config.restart.on == common::RestartOn::Always; 206 206 207 - service.status = moxsm_core_v1::ServiceStatus::Dead 207 + service.status = moxservice_core_v1::ServiceStatus::Dead 208 208 } else { 209 209 should_restart = service.config.restart.on 210 210 == common::RestartOn::Failure 211 211 || service.config.restart.on == common::RestartOn::Always; 212 212 213 - service.status = moxsm_core_v1::ServiceStatus::Failed; 213 + service.status = moxservice_core_v1::ServiceStatus::Failed; 214 214 }; 215 215 service.pending_start = false; 216 216 service.children_ready = false; ··· 231 231 service.config.name 232 232 ); 233 233 service.process = None; 234 - service.status = moxsm_core_v1::ServiceStatus::Failed; 234 + service.status = moxservice_core_v1::ServiceStatus::Failed; 235 235 service.pending_start = false; 236 236 service.children_ready = false; 237 237 service.started_at = 0; ··· 254 254 let restart_delay = state.services[index].config().restart.sec.as_millis(); 255 255 if let Err(err) = handle.insert_source( 256 256 timer::Timer::from_duration(time::Duration::from_millis(restart_delay)), 257 - move |_, _, state: &mut crate::Moxsm<M>| { 257 + move |_, _, state: &mut crate::Moxservice<M>| { 258 258 let log_dir = rc::Rc::clone(&state.log_dir); 259 259 let Some(service) = state.services.get_mut(index) else { 260 260 return timer::TimeoutAction::Drop; ··· 291 291 })?; 292 292 293 293 self.process = Some(process); 294 - self.status = moxsm_core_v1::ServiceStatus::Running; 294 + self.status = moxservice_core_v1::ServiceStatus::Running; 295 295 self.started_at = since_epoch.as_secs() as u32; 296 296 self.children_ready = true; 297 297 log::info!("started service {}", self.config.name); 298 298 Ok(()) 299 299 } 300 300 Err(e) => { 301 - self.status = moxsm_core_v1::ServiceStatus::Failed; 301 + self.status = moxservice_core_v1::ServiceStatus::Failed; 302 302 Err(anyhow::anyhow!( 303 303 "failed to start service {}: {e}", 304 304 self.config.name ··· 314 314 } 315 315 316 316 self.started_at = 0; 317 - self.status = moxsm_core_v1::ServiceStatus::Dead; 317 + self.status = moxservice_core_v1::ServiceStatus::Dead; 318 318 self.children_ready = false; 319 319 log::info!("stopped service {}", self.config.name); 320 320 } 321 321 322 322 fn restart( 323 323 &mut self, 324 - handle: calloop::LoopHandle<'static, crate::Moxsm<M>>, 324 + handle: calloop::LoopHandle<'static, crate::Moxservice<M>>, 325 325 log_dir: rc::Rc<path::Path>, 326 326 cgroup_procs: fs::File, 327 327 ) -> anyhow::Result<()> {
+2 -2
flake.nix
··· 21 21 }); 22 22 23 23 packages = tooling.lib.forAllSystems (pkgs: { 24 - moxsm = pkgs.callPackage ./nix/package.nix { 24 + moxservice = pkgs.callPackage ./nix/package.nix { 25 25 rustPlatform = pkgs.makeRustPlatform { 26 26 cargo = pkgs.rustToolchain; 27 27 rustc = pkgs.rustToolchain; 28 28 }; 29 29 }; 30 - default = self.packages.${pkgs.stdenv.hostPlatform.system}.moxsm; 30 + default = self.packages.${pkgs.stdenv.hostPlatform.system}.moxservice; 31 31 }); 32 32 }; 33 33 }
+2 -2
nix/package.nix
··· 6 6 cargoToml = fromTOML (builtins.readFile ../Cargo.toml); 7 7 in 8 8 rustPlatform.buildRustPackage { 9 - pname = "moxsm"; 9 + pname = "moxservice"; 10 10 inherit (cargoToml.workspace.package) version; 11 11 12 12 cargoLock = { ··· 48 48 49 49 meta = { 50 50 description = "Wayland-native command-line automation tool."; 51 - homepage = "https://git.r0chd.pl/mox-desktop/moxsm"; 51 + homepage = "https://git.r0chd.pl/mox-desktop/moxservice"; 52 52 license = lib.licenses.gpl3; 53 53 maintainers = builtins.attrValues { inherit (lib.maintainers) r0chd; }; 54 54 platforms = lib.platforms.linux;
+4 -4
protocols/moxsm_core_v1.xml protocols/moxservice_core_v1.xml
··· 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 - <protocol name="moxsm_core_v1" version="1"> 3 - <object name="moxsm_core_manager" version="1"> 2 + <protocol name="moxservice_core_v1" version="1"> 3 + <object name="moxservice_core_manager" version="1"> 4 4 <description summary="core manager object"> 5 5 Core manager object for service discovery and service control operations. 6 6 </description> ··· 42 42 Creates a service object for the named service. 43 43 </description> 44 44 <arg name="name" type="varchar" summary="service name"/> 45 - <returns iface="moxsm_core_service"/> 45 + <returns iface="moxservice_core_service"/> 46 46 </c2s> 47 47 <c2s name="reload"> 48 48 <description summary="reload active closure"> ··· 56 56 </c2s> 57 57 </object> 58 58 59 - <object name="moxsm_core_service" version="1"> 59 + <object name="moxservice_core_service" version="1"> 60 60 <description summary="service object"> 61 61 Per-service object that emits state and metadata. An initial property batch is sent 62 62 immediately after the object is created, and future updates are sent on change.
+3 -3
protocols/moxsm_journald_v1.xml protocols/moxservice_journald_v1.xml
··· 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 - <protocol name="moxsm_journald_v1" version="1"> 3 - <object name="moxsm_journal_manager" version="1"> 2 + <protocol name="moxservice_journald_v1" version="1"> 3 + <object name="moxservice_journal_manager" version="1"> 4 4 <description summary="manager for the internal journal service"> 5 5 Coordinates subscriptions, queries, and control operations for journald-style logging. 6 6 </description> ··· 77 77 </c2s> 78 78 </object> 79 79 80 - <object name="moxsm_journal_writer" version="1"> 80 + <object name="moxservice_journal_writer" version="1"> 81 81 <description summary="per-service writer handle"> 82 82 Services connect here to append log entries into the journal. 83 83 </description>
+4 -4
protocols/moxsm_service_registration_v1.xml protocols/moxservice_service_registration_v1.xml
··· 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 - <protocol name="moxsm_service_registration_v1" version="1"> 3 - <object name="moxsm_service_registration_manager" version="1"> 2 + <protocol name="moxservice_service_registration_v1" version="1"> 3 + <object name="moxservice_service_registration_manager" version="1"> 4 4 <description summary="register services whose lifetime matches the service object"/> 5 5 <s2c name="service_created"> 6 6 <arg name="name" type="varchar" summary="logical service name"/> ··· 14 14 </s2c> 15 15 <c2s name="create_service"> 16 16 <arg name="name" type="varchar" summary="unique service name"/> 17 - <returns iface="moxsm_service"/> 17 + <returns iface="moxservice_service"/> 18 18 </c2s> 19 19 <c2s name="destroy" destructor="true"> 20 20 </c2s> 21 21 </object> 22 22 23 - <object name="moxsm_service" version="1"> 23 + <object name="moxservice_service" version="1"> 24 24 <description summary="builder/runner whose service lifetime tracks the object"> 25 25 After `configure` transitions the builder into the running phase, sending further 26 26 configuration events is a fatal protocol error; the service is immutable after running.
+3 -3
protocols/moxsm_user_v1.xml protocols/moxservice_user_v1.xml
··· 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 - <protocol name="moxsm_user_v1" version="1"> 3 - <object name="moxsm_user_manager" version="1"> 2 + <protocol name="moxservice_user_v1" version="1"> 3 + <object name="moxservice_user_manager" version="1"> 4 4 <description summary="user manager registration object"> 5 - Coordinates registration of a per-user moxsm instance with the system manager. 5 + Coordinates registration of a per-user moxservice instance with the system manager. 6 6 </description> 7 7 <s2c name="registered"> 8 8 <description summary="user manager registered">