fix: expose Trojan logs and build metadata
This commit is contained in:
@@ -5,7 +5,7 @@ After=network.target network-online.target nss-lookup.target mysql.service maria
|
||||
[Service]
|
||||
Type=simple
|
||||
StandardError=journal
|
||||
ExecStart=/usr/bin/trojan/trojan /usr/local/etc/trojan/config.json
|
||||
ExecStart=/bin/sh -c '/usr/bin/trojan/trojan /usr/local/etc/trojan/config.json >> /var/log/trojan.log 2>&1'
|
||||
ExecReload=/bin/kill -HUP $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=3s
|
||||
|
||||
@@ -96,7 +96,14 @@ func Log(serviceName string, line int) {
|
||||
|
||||
// LogChan 指定服务实时日志, 返回chan
|
||||
func LogChan(serviceName, param string, closeChan chan byte) (chan string, error) {
|
||||
cmd := exec.Command("bash", "-c", fmt.Sprintf("journalctl -f -u %s -o cat %s", serviceName, param))
|
||||
logFile := fmt.Sprintf("/var/log/%s.log", serviceName)
|
||||
command := fmt.Sprintf("journalctl -f -u %s -o cat %s", serviceName, param)
|
||||
// docker-systemctl has no persistent journal. Compatibility images write
|
||||
// service output to /var/log/<service>.log instead.
|
||||
if IsExists(logFile) {
|
||||
command = fmt.Sprintf("tail %s -F %s", param, logFile)
|
||||
}
|
||||
cmd := exec.Command("bash", "-c", command)
|
||||
|
||||
stdout, _ := cmd.StdoutPipe()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user