mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
adds log fetch feature to agent
This commit is contained in:
committed by
Aiden McClelland
parent
97a85d6e01
commit
18df87b8f5
@@ -13,6 +13,7 @@
|
||||
/v0/specs SpecsR GET
|
||||
/v0/metrics MetricsR GET
|
||||
|
||||
/v0/logs LogsR GET
|
||||
/v0/sshKeys SshKeysR GET POST
|
||||
/v0/sshKeys/#Text SshKeyByFingerprintR DELETE
|
||||
/v0/password PasswordR PATCH
|
||||
|
||||
@@ -28,6 +28,11 @@ import Lib.SystemPaths hiding ( (</>) )
|
||||
import Lib.Tor
|
||||
import Settings
|
||||
import Control.Carrier.Lift ( runM )
|
||||
import System.Process
|
||||
import qualified UnliftIO
|
||||
import System.FileLock
|
||||
import Yesod.Core.Content ( typePlain )
|
||||
import Conduit
|
||||
|
||||
getVersionR :: Handler AppVersionRes
|
||||
getVersionR = pure . AppVersionRes $ agentVersion
|
||||
@@ -69,3 +74,9 @@ patchServerR = do
|
||||
getGitR :: Handler Text
|
||||
getGitR = pure $embedGitRevision
|
||||
|
||||
getLogsR :: Handler TypedContent
|
||||
getLogsR = do
|
||||
let debugLock = "/root/agent/tmp/debug.lock"
|
||||
UnliftIO.bracket (liftIO $ lockFile debugLock Exclusive) (liftIO . unlockFile) $ const $ do
|
||||
liftIO $ callCommand "journalctl -u agent --since \"1 hour ago\" > /root/agent/tmp/debug.log"
|
||||
respondSource typePlain $ sourceFile "/root/agent/tmp/debug.log" .| awaitForever sendChunkBS
|
||||
|
||||
Reference in New Issue
Block a user