運動伺服器未啟動

運動伺服器未啟動

我有一個帶有 Motion v 4.0 的網頁伺服器,但 Motion 不會在啟動時啟動,我必須告訴它每次啟動,然後sudo motion -b一切都很酷,直到我需要重新啟動。我嘗試過編輯配置文件,/etc/motion/motion.conf並且 /etc/defualt/motion

包含變數:start_motion_daemon=yes 哪個應該在啟動時啟動進程?

但當我去檢查時,該進程從未運行。我嘗試設定 rc.local,但 ubuntu 似乎不再這樣做了?

我嘗試使用 systemctl 啟用該服務:

sudo systemctl enable motion
motion.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable motion

但該服務永遠不會啟用,甚至不會開啟。然後我查看了日誌:

[1:ml1] [NTC] [VID] [Jun 16 07:26:10] v4l2_get_capability: - VIDEO_CAPTURE
[1:ml1] [NTC] [VID] [Jun 16 07:26:10] v4l2_get_capability: - STREAMING
[1:ml1] [NTC] [VID] [Jun 16 07:26:10] v4l2_select_input: name = "Camera 1", type 0x00000002, status 00000000
[0:web_control] [NTC] [STR] [Jun 16 07:26:10] http_bindsock: error binding on 127.0.0.1 port 8080
[1:ml1] [NTC] [VID] [Jun 16 07:26:10] v4l2_select_input: - CAMERA
[0:web_control] [NTC] [STR] [Jun 16 07:26:10] motion_web_control: motion-httpd thread exit
[1:ml1] [ERR] [VID] [Jun 16 07:26:10] v4l2_select_input: Error selecting input 0 VIDIOC_S_INPUT: Device or resource busy
[1:ml1] [NTC] [VID] [Jun 16 07:26:10] vid_v4lx_start: Using V4L1
[1:ml1] [NTC] [ALL] [Jun 16 07:26:10] image_ring_resize: Resizing pre_capture buffer to 1 items
[1:ml1] [ERR] [ALL] [Jun 16 07:26:20] motion_init: Error capturing first image
[1:ml1] [NTC] [STR] [Jun 16 07:26:20] http_bindsock: error binding on any IPv4 address port 8081
[1:ml1] [ERR] [ALL] [Jun 16 07:26:20] motion_init: Problem enabling motion-stream server in port 8081: Address already in use
[1:ml1] [NTC] [ALL] [Jun 16 07:26:20] motion_loop: Thread exiting
[1:ml1] [NTC] [VID] [Jun 16 07:26:20] vid_close: Closing video device /dev/video0
[0:motion] [NTC] [ALL] [Jun 16 07:26:21] main: Motion thread 1 restart
[1:ml1] [NTC] [ALL] [Jun 16 07:26:21] motion_init: Camera 0 started: motion detection Enabled
[1:ml1] [NTC] [VID] [Jun 16 07:26:21] vid_v4lx_start: Using videodevice /dev/video0 and input -1
[1:ml1] [NTC] [VID] [Jun 16 07:26:21] v4l2_get_capability: 
------------------------
cap.driver: "uvcvideo"
cap.card: "HD Webcam C615"
cap.bus_info: "usb-ff540000.usb-1.1"
cap.capabilities=0x84200001
------------------------
[1:ml1] [NTC] [VID] [Jun 16 07:26:21] v4l2_get_capability: - VIDEO_CAPTURE
[1:ml1] [NTC] [VID] [Jun 16 07:26:21] v4l2_get_capability: - STREAMING
[1:ml1] [NTC] [VID] [Jun 16 07:26:21] v4l2_select_input: name = "Camera 1", type 0x00000002, status 00000000
[1:ml1] [NTC] [VID] [Jun 16 07:26:21] v4l2_select_input: - CAMERA
[1:ml1] [ERR] [VID] [Jun 16 07:26:21] v4l2_select_input: Error selecting input 0 VIDIOC_S_INPUT: Device or resource busy
[1:ml1] [NTC] [VID] [Jun 16 07:26:21] vid_v4lx_start: Using V4L1
[1:ml1] [NTC] [ALL] [Jun 16 07:26:21] image_ring_resize: Resizing pre_capture buffer to 1 items
(END)

閱讀日誌,我認為該進程正在運行,但事實並非如此。

根據建議,我嘗試設定一個 cron 作業,運行sudo crontab -e 並添加行 @reboot/usr/bin/motion -b

但重新啟動後,運動守護程式仍未運作。

我只想知道在啟動時啟動此過程的現代方法。 Ubuntu 18.04,LXDE。

答案1

你可以使用 cron @reboot

sudo crontab -e

並添加行

@reboot   /path/to/bin/motion -b

答案2

首先,嘗試使用 手動運行它sudo -u motion motion。如果有效,則問題是由 systemd 引起的。

這是違反直覺的,但對於 systemd,您應該daemon off在motion.conf 中進行設定。

PS:/etc/defualt/motionUbuntu/Debian 中可能不需要該檔案。

相關內容