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