improved process logging

This commit is contained in:
mercury
2025-12-03 01:25:53 +04:00
parent 3bdebd95ab
commit 7d81eeeddd
3 changed files with 8 additions and 4 deletions
+4 -3
View File
@@ -4686,7 +4686,7 @@ DNS-over-HTTPS with IP:
if (!file_exists('/config/dnstt/server.key')) {
$this->ssh("dnstt-server -gen-key -privkey-file /dnstt/server.key -pubkey-file /dnstt/server.pub", 'dnstt');
}
$this->ssh("dnstt-server -udp :53 -privkey-file /dnstt/server.key {$c['dnsttDomain']} 127.0.0.1:22", 'dnstt' , false);
$this->ssh("dnstt-server -udp :53 -privkey-file /dnstt/server.key {$c['dnsttDomain']} 127.0.0.1:22", 'dnstt' , false, '/logs/dnstt');
}
}
@@ -9253,7 +9253,7 @@ DNS-over-HTTPS with IP:
$this->send($this->input['chat'], "disconnect: \n" . var_export($args, true) . "\n", $this->input['message_id']);
}
public function ssh($cmd, $service = 'wg', $wait = true)
public function ssh($cmd, $service = 'wg', $wait = true, $log = '/dev/null')
{
try {
$c = ssh2_connect($service, 22);
@@ -9270,9 +9270,10 @@ DNS-over-HTTPS with IP:
// nohup запускает процесс независимо от SSH-сессии
// & переносит процесс в фон
// </dev/null >/dev/null 2>&1 перенаправляет все потоки ввода-вывода
$cmd = "nohup $cmd </dev/null >/dev/null 2>&1 &";
$cmd = "nohup sh -c \"$cmd 2>&1 | tee -a $log >&3\" 3>/proc/1/fd/1 </dev/null &";
}
$s = ssh2_exec($c, $cmd);
if (empty($s)) {
throw new Exception("exec fail: \n$cmd\n" . var_export($s, true));
+2 -1
View File
@@ -121,4 +121,5 @@ PasswordAuthentication yes
AllowTcpForwarding yes
PermitTunnel yes
GatewayPorts yes
X11Forwarding yes
X11Forwarding yes
LogLevel QUIET
+2
View File
@@ -550,6 +550,7 @@ services:
volumes:
- ./config/.profile:/root/.ashrc:ro
- ./ssh:/ssh
- ./logs:/logs
- ./config/sshd_config:/etc/ssh/sshd_config
- ./config/dnstt:/dnstt
- ./scripts/start_dnstt.sh:/start_dnstt.sh
@@ -580,6 +581,7 @@ services:
- ./ssh:/ssh
- ./config/sshd_config:/etc/ssh/sshd_config
- ./certs:/certs
- ./logs:/logs
- ./config:/config
- ./scripts/start_hysteria.sh:/start_hysteria.sh
hostname: hysteria