systemctl enable X.service command - troubleshooting help

This forum is for Marvell Kirkwood devices such as the GoFlex Home/Net, PogoPlug v1/v2, SheevaPlug, and ZyXEL devices.

systemctl enable X.service command - troubleshooting help

Postby permitivity » Mon Sep 02, 2013 9:15 pm

Hello,
The normal way to get "motion" to start at boot is to just use
$this->bbcode_second_pass_quote('', 's')ystemctl enable motion


This works for me like it's suppose to.

There's a known issue with "motion" on some USB webcams. It seems you have to run "fswebcam" before you run "motion" for a couple models of usb webcams. Qui's tutorial has a trick where you put the fswebcam command in a .service file, and run it before you run "motion" - all done during startup. So it looks like this:

nano /etc/systemd/system/motion.service
$this->bbcode_second_pass_code('', '
[Unit]
Description=motion camera

[Service]
ExecStartPre=/usr/bin/fswebcam -r 320x240 -d /dev/video0 -v /dev/null
ExecStart=/usr/bin/motion

[Install]
WantedBy=multi-user.target
')

Then you enable it at startup, using the service file instead of the motion process command:
$this->bbcode_second_pass_quote('', 's')ystemctl enable motion.service


I've used this on my old pogoplug install from a few weeks ago. Now it doesn't seem to work. I can issue

$this->bbcode_second_pass_quote('', 's')ystemctl start motion.service


And motion starts fine. But when I use the "systemctl enable motion.service", no motion process starts after boot. It's almost like it's not running motion.service at all. I don't know where to look to try to find error logs. I can verify that a link "motion.service" exists in /etc/systemd/system/multi-user.target.wants/. But the motion process isn't running after boot.

Any ideas on troubleshooting?
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am
Top

Re: systemctl enable X.service command - troubleshooting hel

Postby moonman » Mon Sep 02, 2013 11:01 pm

As far as I know motion = motion.service, you can drop the .service part. Check systemctl status motion after boot.
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: systemctl enable X.service command - troubleshooting hel

Postby permitivity » Tue Sep 03, 2013 3:14 am

I didn't know about that. I get this when I run status:

$this->bbcode_second_pass_code('', '
[root@alarm /]# systemctl status motion
motion.service - motion camera
Loaded: loaded (/etc/systemd/system/motion.service; enabled)
Active: inactive (dead) since Wed 1969-12-31 17:00:22 MST; 43 years 8 months ago
Process: 129 ExecStart=/usr/bin/motion (code=exited, status=0/SUCCESS)
Process: 97 ExecStartPre=/usr/bin/fswebcam -r 320x240 -d /dev/video0 -v /dev/null (code=exited, status=0/SUCCESS)
')

If I systemctl disable motion.service and then reboot, I get this output:

$this->bbcode_second_pass_code('', '
[root@alarm ~]# systemctl status motion.service
motion.service - motion camera
Loaded: loaded (/etc/systemd/system/motion.service; disabled)
Active: inactive (dead)

Sep 02 14:19:18 alarm motion[360]: [1] "Saturation", default 83, cu...83
Sep 02 14:19:18 alarm motion[360]: [1] mmap information:
Sep 02 14:19:18 alarm motion[360]: [1] frames=4
Sep 02 14:19:18 alarm motion[360]: [1] 0 length=1843200
Sep 02 14:19:18 alarm motion[360]: [1] 1 length=1843200
Sep 02 14:19:18 alarm motion[360]: [1] 2 length=1843200
Sep 02 14:19:18 alarm motion[360]: [1] 3 length=1843200
Sep 02 14:19:19 alarm motion[360]: [1] Resizing pre_capture buffer to 1 items
Sep 02 14:19:19 alarm motion[360]: [1] Started stream webcam server in port 7081
Sep 02 14:19:19 alarm motion[360]: [1] Resizing pre_capture buffer to 3 items
Sep 02 14:19:25 alarm systemd[1]: Stopping motion camera...
')

So, it looks like it tried to run motion, but then it exited? The timestamp on it looks like the system hadn't gotten the correct time from the network yet. But no idea why it's exiting. Running the command "systemctl start motion.service" works fine, and it executes the fswebcam command prior to "motion".

I might also be going about this the wrong way. Qui's tutorial might have worked for some previous version of Arch (although my other Pogoplug is a 3.1.10 ALARM). I'm just looking for a way to run fswebcam command before running the motion command at boot. The "motion.service" file that Qui made up could be renamed "my_startup_command.service", and enabled via systemctl enable my_startup_command.service? I thought Qui just happened to name the file "motion.service"?

And just to check my understanding, "systemctl enable filename.x" tell Arch to run that file at boot right? And "systemctl disable filename.x" tells Arch to take that out of boot. And "systemctl start filename.x" and "systemctl stop filename.x" will start or stop the executables in that file right away...or something like that? I've been using the enable and disable on the .service files to change what runs at boot.
Last edited by permitivity on Tue Sep 03, 2013 3:27 am, edited 1 time in total.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am

Re: systemctl enable X.service command - troubleshooting hel

Postby moonman » Tue Sep 03, 2013 3:27 am

The file needs to have .service in its name, but you can drop that when you are calling systemctl. Try adding after network.target.
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: systemctl enable X.service command - troubleshooting hel

Postby permitivity » Tue Sep 03, 2013 3:33 am

$this->bbcode_second_pass_quote('', 'T')ry adding after network.target.


I did try that, like you suggested with the audio baby monitor I was working on. I get the same result with or without the After=network.target. Motion isn't running after boot up - at least not by the time I log in to check it. And I actually want motion to run even if no network is available in this case since it's not necessarily setting up a network communication, just recording images.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am
Top

Re: systemctl enable X.service command - troubleshooting hel

Postby moonman » Tue Sep 03, 2013 5:11 am

Maybe when the service starts your webcam hasn't been initialised yet. Try adding "sleep 30" in execsrartpre in front of everything else
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: systemctl enable X.service command - troubleshooting hel

Postby permitivity » Tue Sep 03, 2013 7:02 am

Ok, added the sleep line to the .service file. I also changed the name to "webcam1.service", just to see what happens, and I'm using "systemctl enable webcam1.service". But I still get the same result. But I have something new to report.

/etc/systemd/system/webcam1.service
$this->bbcode_second_pass_code('', '
[Unit]
Description=motion camera

[Service]
ExecStartPre=/bin/sleep 30
ExecStartPre=/usr/bin/fswebcam -r 320x240 -d /dev/video0 -v /dev/null
ExecStart=/usr/bin/motion

[Install]
WantedBy=multi-user.target
')



Again, motion never really runs when I ssh in. But, I do get this error:
$this->bbcode_second_pass_code('', '
[root@alarm /]# systemctl status webcam1.service
webcam1.service - motion camera
Loaded: loaded (/etc/systemd/system/webcam1.service; enabled)
Active: inactive (dead) since Mon 2013-09-02 23:53:54 MDT; 56s ago
Process: 289 ExecStart=/usr/bin/motion (code=exited, status=0/SUCCESS)
Process: 286 ExecStartPre=/usr/bin/fswebcam -r 320x240 -d /dev/video0 -v /dev/ null (code=exited, status=0/SUCCESS)
Process: 100 ExecStartPre=/bin/sleep 30 (code=exited, status=0/SUCCESS)

Sep 02 23:53:51 alarm motion[290]: [1] 3 length=1843200
Sep 02 23:53:51 alarm motion[290]: [1] Resizing pre_capture buffer to 1 items
Sep 02 23:53:52 alarm motion[290]: [1] Started stream webcam server in port 7081
Sep 02 23:53:52 alarm motion[290]: [1] Resizing pre_capture buffer to 3 items
[b]Sep 02 23:53:52 alarm motion[290]: [1] Video device fatal error - Closing v...ce[/b]
Sep 02 23:53:52 alarm motion[290]: [1] Closing video device /dev/video0
Sep 02 23:53:52 alarm motion[290]: [0] httpd Closing
Sep 02 23:53:52 alarm motion[290]: [0] httpd thread exit
Sep 02 23:53:54 alarm motion[290]: [0] Motion terminating
Sep 02 23:53:54 alarm motion[290]: [0] Removed process id file (pid file).
')

Interesting. If I use "systemctl enable motion", which is what most people use if they don't have to run fswebcam, motion seems to start fine at boot and runs fine. I tried this a couple times, seems to work.

Also, I found out something new. If I use "systemctl start webcam1.service" at the shell, motion starts and runs for about 5 minutes before crapping out. I tried this a few times too, and the process stops by itself after a few minutes, or sometimes it doesn't even start.

So, using the webcam1.service is problematic whether it's using the systemctl enable or systemctl start. But motion runs fine using other starting methods.

Here's the systemctl status output from a "systemctl start webcam1.service" call. It's slightly different than from systemctl enable up above. Oh, and I added another 10 second wait between calling fswebcam and motion just for kicks.

$this->bbcode_second_pass_code('', '
[root@alarm system]# systemctl status webcam1.service
webcam1.service - motion camera
Loaded: loaded (/etc/systemd/system/webcam1.service; disabled)
Active: failed (Result: timeout) since Tue 2013-09-03 01:03:58 MDT; 1min 23s ago
Process: 342 ExecStart=/usr/bin/motion (code=exited, status=0/SUCCESS)
Process: 339 ExecStartPre=/bin/sleep 10 (code=exited, status=0/SUCCESS)
Process: 336 ExecStartPre=/usr/bin/fswebcam -r 320x240 -d /dev/video0 -v /dev/null (code=exited, status=0/SUCCESS)
Process: 333 ExecStartPre=/bin/sleep 30 (code=exited, status=0/SUCCESS)

Sep 03 01:02:28 alarm motion[343]: [1] frames=4
Sep 03 01:02:28 alarm motion[343]: [1] 0 length=1843200
Sep 03 01:02:28 alarm motion[343]: [1] 1 length=1843200
Sep 03 01:02:28 alarm motion[343]: [1] 2 length=1843200
Sep 03 01:02:28 alarm motion[343]: [1] 3 length=1843200
Sep 03 01:02:29 alarm motion[343]: [1] Resizing pre_capture buffer to 1 items
Sep 03 01:02:29 alarm motion[343]: [1] Started stream webcam server in port 7081
Sep 03 01:02:29 alarm motion[343]: [1] Resizing pre_capture buffer to 3 items
Sep 03 01:03:57 alarm systemd[1]: webcam1.service stopping timed out. Killing.
Sep 03 01:03:58 alarm systemd[1]: Unit webcam1.service entered failed state.

')
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am

Re: systemctl enable X.service command - troubleshooting hel

Postby grayman4hire » Tue Sep 03, 2013 9:31 pm

@permitivity, sorry I'm confused on your issue.

However, I did update the motion.service file to include the "after=network.target" since I know it wouldn't hurt and should have been there to begin with.
grayman4hire
 
Posts: 350
Joined: Sat Sep 29, 2012 12:03 am
Location: SF, CA

Re: systemctl enable X.service command - troubleshooting hel

Postby permitivity » Wed Sep 04, 2013 1:44 am

Hey grayman,
Yeah, I'm not sure what's going on with my installation. When I use systemctl enable to make a .service file boot motion, motion doesn't run correctly. When I use systemctl start x.service to start motion, motion starts usually, but crashes in a few minutes. If I just systemctl enable motion, without using the service file, motion runs fine. Or if I just start motion on console, it starts fine.

Tried a few things like delaying the motion call in the service file, or waiting until network.target acquired, but nothing helps with the systemctl enable call.

No ideas. :?

All this is to get Arch to run fswebcam command prior to calling Motion, since some webcams have issues.
permitivity
 
Posts: 141
Joined: Mon Feb 18, 2013 3:08 am

Re: systemctl enable X.service command - troubleshooting hel

Postby moonman » Wed Sep 04, 2013 10:26 am

You seem very confused with what service files are and how they work. <servicename>.service is exactly the same thing as just <servicename> . In both cases the same service file gets called. As I said above, ".service" part does not have to be typed out if you want because it's shorter to write it that way.
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am


Return to Marvell Kirkwood

Who is online

Users browsing this forum: No registered users and 4 guests