mirror of
https://github.com/vale981/stream
synced 2025-03-05 10:01:39 -05:00
transition systemd commands to --no-block
This commit is contained in:
parent
9c1d9d17bd
commit
040d6e8106
2 changed files with 15 additions and 9 deletions
|
@ -76,8 +76,9 @@
|
|||
;; The commands are implemented synchronousily.
|
||||
|
||||
(defn- run-systemd-command! [& commands]
|
||||
(let [result (apply sh "systemctl" "-q" "--job-mode=replace"
|
||||
"--user" "--job-mode=replace" commands)]
|
||||
(let [result (apply sh "systemctl" "--no-block"
|
||||
"--job-mode=replace" "--user" "--job-mode=replace"
|
||||
commands)]
|
||||
(if (= (:exit result) 0)
|
||||
true
|
||||
(throw+ {:type ::systemd-error
|
||||
|
|
|
@ -66,21 +66,26 @@
|
|||
|
||||
(testing "starting the service"
|
||||
(systemd/start-service! name)
|
||||
(a/<!! (a/timeout 1000))
|
||||
(while (= :activating (systemd/get-service-state! name))
|
||||
(a/<!! (a/timeout 1000)))
|
||||
(is (= :active (systemd/get-service-state! name))))
|
||||
|
||||
(testing "stopping the service"
|
||||
(systemd/stop-service! name)
|
||||
(while (= :deactivating (systemd/get-service-state! name))
|
||||
(a/<!! (a/timeout 1000)))
|
||||
(is (= :inactive (systemd/get-service-state! name))))
|
||||
|
||||
(testing "reading the logs"
|
||||
(let [logs (journal/get-logs! name)]
|
||||
(is (= (:message (second logs)) "test"))
|
||||
(is (= (:message (nth logs 2)) "error"))))
|
||||
|
||||
(testing "stopping the service"
|
||||
(systemd/stop-service! name)
|
||||
(is (= :inactive (systemd/get-service-state! name))))
|
||||
|
||||
(testing "restarting the service"
|
||||
(systemd/start-service! name)
|
||||
(systemd/restart-service! name)
|
||||
(while (= :activating (systemd/get-service-state! name))
|
||||
(a/<!! (a/timeout 1000)))
|
||||
(is (= :active (systemd/get-service-state! name))))
|
||||
|
||||
(testing "enabling the service"
|
||||
|
@ -141,7 +146,7 @@
|
|||
(is (= "a-b-c-d-" (#'api/sanitize-process-name "a*b C?d.")))))
|
||||
|
||||
(deftest ffmpeg-process-management
|
||||
(let [config {:cam-ip "nonexistent"
|
||||
(let [config {:cam-ip "0.0.0.0"
|
||||
:cam-rtsp-port "554"
|
||||
:profile "bla"
|
||||
:stream-server "server"
|
||||
|
@ -175,7 +180,7 @@
|
|||
(let [prom (api/wait-for!
|
||||
(:supervisor proc)
|
||||
:event :failed
|
||||
:timeout 10000)]
|
||||
:timeout 100000)]
|
||||
(api/start-process! proc)
|
||||
(is (not (= :timeout @prom)))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue