Fix sudo nginx and psql commands to use full paths
- Change nginx command from 'nginx' to '/run/current-system/sw/bin/nginx' - Change psql command from 'psql' to '/run/current-system/sw/bin/psql' - This ensures sudo rules can properly match the commands with full paths
This commit is contained in:
parent
92d6b42837
commit
7af4f09ca2
@ -526,7 +526,7 @@ impl ServiceCollector {
|
||||
|
||||
async fn get_postgres_connections(&self) -> Option<String> {
|
||||
let output = Command::new("sudo")
|
||||
.args(["-u", "postgres", "psql", "-t", "-c", "SELECT count(*) FROM pg_stat_activity WHERE state = 'active';"])
|
||||
.args(["-u", "postgres", "/run/current-system/sw/bin/psql", "-t", "-c", "SELECT count(*) FROM pg_stat_activity WHERE state = 'active';"])
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.output()
|
||||
@ -585,10 +585,10 @@ impl ServiceCollector {
|
||||
None => {
|
||||
// Fallback to default nginx -T
|
||||
let mut cmd = if self.is_running_as_root() {
|
||||
Command::new("nginx")
|
||||
Command::new("/run/current-system/sw/bin/nginx")
|
||||
} else {
|
||||
let mut cmd = Command::new("sudo");
|
||||
cmd.arg("nginx");
|
||||
cmd.arg("/run/current-system/sw/bin/nginx");
|
||||
cmd
|
||||
};
|
||||
|
||||
@ -615,10 +615,10 @@ impl ServiceCollector {
|
||||
|
||||
// Use the specific config file
|
||||
let mut cmd = if self.is_running_as_root() {
|
||||
Command::new("nginx")
|
||||
Command::new("/run/current-system/sw/bin/nginx")
|
||||
} else {
|
||||
let mut cmd = Command::new("sudo");
|
||||
cmd.arg("nginx");
|
||||
cmd.arg("/run/current-system/sw/bin/nginx");
|
||||
cmd
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user