Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Users

systemctl

 

 

MythTV users RSS feed   Index | Next | Previous | View Threaded


jam at tigger

Jul 10, 2012, 6:29 AM

Post #1 of 10 (526 views)
Permalink
systemctl

G'day all

I'm going crazy trying to start mythbackend using systemctrl

If anybody can help --- pretty please ...

Got the (fedora) systemctl file from the wiki: http://www.mythtv.org/wiki/Systemd_mythbackend_Configuration

It does not start and status is

sandypit:/mnt/store/mythlogs # systemctl status mythbackend.service
mythbackend.service - MythTV backend service
Loaded: loaded (/etc/systemd/system/mythbackend.service; enabled)
Active: inactive (dead) since Tue, 10 Jul 2012 12:50:41 +0800; 30s ago
Process: 3036 ExecStart=/usr/local/bin/mythbackend --daemon --logpath /mnt/store/mythlogs --pidfile /var/run/myth.pid (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/mythbackend.service

The log file IS created, but is empty.
I can pickup the ExecStart line, execute it, and it does run normally.

Help ...
James
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


imntreal at gmail

Jul 10, 2012, 6:37 AM

Post #2 of 10 (508 views)
Permalink
Re: systemctl [In reply to]

On Tue, Jul 10, 2012 at 9:29 AM, James Linder <jam [at] tigger> wrote:
> I'm going crazy trying to start mythbackend using systemctrl
>
> If anybody can help --- pretty please ...
>
> I can pickup the ExecStart line, execute it, and it does run normally.


Is the HOME variable correct for your system?

Environment=HOME=/usr/share/mythtv
# or Environment=HOME=/home/mythtv

=-Jameson
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


hobbes1069 at gmail

Jul 10, 2012, 6:37 AM

Post #3 of 10 (507 views)
Permalink
Re: systemctl [In reply to]

On Tue, Jul 10, 2012 at 8:29 AM, James Linder <jam [at] tigger> wrote:
> G'day all
>
> I'm going crazy trying to start mythbackend using systemctrl
>
> If anybody can help --- pretty please ...
>
> Got the (fedora) systemctl file from the wiki: http://www.mythtv.org/wiki/Systemd_mythbackend_Configuration

Whoops!!! Looks like there's an error in the wiki version!

Just so anyone having this issue hopefully finds this thread I'll
explain it in full again... (in other words, this is not directed at
you, James)

There are many options for how to run mythbackend with SystemD but
one decision you

*MUST*
*MUST*
*MUST*

make is if you're going to run:

Type=simple

or

Type=forking

If you use Type=simple (which is my recommendation) then you *CANNOT*
use the "--daemon" option because SystemD is not expecting the daemon
to fork!!!

If you use Type=forking then you *MUST* use the "--daemon" option as
well as specify a PID file, "--pidfile" in ExecStart *AND* you must
set the PIDFile= systemd option so it knows where to find the PID
file.

Someone please fix the wiki!

Thanks
Richard
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


hobbes1069 at gmail

Jul 10, 2012, 7:02 AM

Post #4 of 10 (510 views)
Permalink
Re: systemctl [In reply to]

Ok, now that my frustration has subsided :) Here's my recommended
update to the service file on the wiki. This is an update of the
version I package for Fedora...

--- mythbackend.service ---
# Do not edit this file, it will be replaced on update
# If you need to make modifications to this unit file first make a copy in
# /etc/systemd/system

# This file is part of the packaging of MythTV
#
# MythTV is free software; view http://www.mythtv.org
# for more information.
#
# It is sometimes necessary to wait for a capture
# device to finish (hot)plug initialization before
# the backend starts. If this is necessary,
# create a Wants and After entry for all the capture
# devices that one wishes to wait to be created
# before the backend starts using the systemd
# device name mangling names (/dev/some/thing turns
# into dev-some-thing.device). These normally should
# be udev persistent filename rules to avoid confusion.
# See the MythTV wiki for udev persistent filename
# discussions found at:
# http://www.mythtv.org/wiki/Device_Filenames_and_udev
#
# In order to insure that systemd will create a
# device unit for the capture device, one must
# insure that udev will have the tag "systemd"
# (i.e. add TAG+="systemd" to the udev rule).
#
# The MythTV package ships with a default udev
# rule file located in: /lib/udev/rules.d/99-mythbackend.rules

[Unit]
Description=MythTV backend service
After=network.target mysqld.service
# Uncomment the following line if you will be using the mythweb plugin on the
# same system as mythbackend.
#Wants=httpd.service

[Service]
# Type=simple is recommended. If using Type=forking you will need to specify a
# pidfile so systemd knows how to find the forked process PID, otherwise it
# presumes that the process being started will be the remaining process.
#Type=forking
Type=simple

Environment=MYTHCONFDIR=/etc/mythtv
# Default setting assumes a system wide install. Otherwise it should be set to
# the folder containing the .mythtv subfolder containing the config.xml file
Environment=HOME=/usr/share/mythtv

# systemd changes execution from the calling user (possibly root) to this user
# if you have permissions problems or obscure errors try logging in as mythtv
User=mythtv

# Uncomment one of the following...
# Use sysloging rather than separate logging:
#ExecStart=/usr/bin/mythbackend --syslog local7
# If Type=forking is set you must specify the --daemon and --pidfile options:
#ExecStart=/usr/bin/mythbackend --daemon --logpath /var/log/mythtv
--loglevel crit --pidfile /run/mythbackend.pid
# Default setting for Type=simple.
ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv

# Whether systemd will continue over-watch and restart on any halt
#Restart=Restart-always

[Install]
WantedBy=multi-user.target
--- end ---
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


steve.goodey at openreach

Jul 10, 2012, 7:12 AM

Post #5 of 10 (509 views)
Permalink
Re: systemctl [In reply to]

-----Original Message-----
From: mythtv-users-bounces [at] mythtv [mailto:mythtv-users-bounces [at] mythtv] On Behalf Of Richard Shaw
Sent: 10 July 2012 14:38
To: Discussion about MythTV
Subject: Re: [mythtv-users] systemctl

Someone please fix the wiki!

Thanks
Richard


Done.
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


hobbes1069 at gmail

Jul 10, 2012, 7:29 AM

Post #6 of 10 (509 views)
Permalink
Re: systemctl [In reply to]

On Tue, Jul 10, 2012 at 9:12 AM, <steve.goodey [at] openreach> wrote:
>
>> -----Original Message-----
>> From: mythtv-users-bounces [at] mythtv [mailto:mythtv-users-bounces [at] mythtv] On Behalf Of Richard Shaw
>> Sent: 10 July 2012 14:38
>> To: Discussion about MythTV
>> Subject: Re: [mythtv-users] systemctl
>>
>> Someone please fix the wiki!
>
> Done.

Ok, looks like it was taken a bit too literally :)

Something happened when it was pasted in and a lot of newlines seem to
have been lost. Also, now that the default is functional and
alternatives are properly documented in the comments my comments at
the bottom are probably not needed :)

Thanks,
Richard
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


steve.goodey at openreach

Jul 10, 2012, 8:03 AM

Post #7 of 10 (510 views)
Permalink
Re: systemctl [In reply to]

-----Original Message-----
From: mythtv-users-bounces [at] mythtv [mailto:mythtv-users-bounces [at] mythtv] On Behalf Of Richard Shaw
Sent: 10 July 2012 15:30
To: Discussion about MythTV
Subject: Re: [mythtv-users] systemctl

On Tue, Jul 10, 2012 at 9:12 AM, <steve.goodey [at] openreach> wrote:
>
>> -----Original Message-----
>> From: mythtv-users-bounces [at] mythtv
>> [mailto:mythtv-users-bounces [at] mythtv] On Behalf Of Richard Shaw
>> Sent: 10 July 2012 14:38
>> To: Discussion about MythTV
>> Subject: Re: [mythtv-users] systemctl
>>
>> Someone please fix the wiki!
>
> Done.

Ok, looks like it was taken a bit too literally :)

Something happened when it was pasted in and a lot of newlines seem to have been lost. Also, now that the default is functional and alternatives are properly documented in the comments my comments at the bottom are probably not needed :)

Thanks,
Richard

Sorry about that. See what happens when an idiot gets involved. Looks like someone who knows what they are doing has fixed my clumsy efforts.

Steve.
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


newbury at mandamus

Jul 10, 2012, 8:22 AM

Post #8 of 10 (506 views)
Permalink
Re: systemctl [In reply to]

On 07/10/2012 09:29 AM, James Linder wrote:
> G'day all
>
> I'm going crazy trying to start mythbackend using systemctrl
>
> If anybody can help --- pretty please ...
>
> Got the (fedora) systemctl file from the wiki: http://www.mythtv.org/wiki/Systemd_mythbackend_Configuration
>
> It does not start and status is
>
> sandypit:/mnt/store/mythlogs # systemctl status mythbackend.service
> mythbackend.service - MythTV backend service
> Loaded: loaded (/etc/systemd/system/mythbackend.service; enabled)
> Active: inactive (dead) since Tue, 10 Jul 2012 12:50:41 +0800; 30s ago
> Process: 3036 ExecStart=/usr/local/bin/mythbackend --daemon --logpath /mnt/store/mythlogs --pidfile /var/run/myth.pid (code=exited, status=0/SUCCESS)
> CGroup: name=systemd:/system/mythbackend.service
>
> The log file IS created, but is empty.
> I can pickup the ExecStart line, execute it, and it does run normally.
>
> Help ...

Hah! Been there, messed it up too. It is almost assuredly a permissions
problem somewhere. When the backend starts, systemd starts the process
but switches so that mythbackend ends up being run as user mythtv.
Systemd seem to systematically steal error messages (say that three
times quickly) so you do not see what goes wrong. Here is a code snippet
which I put into my rc.local file ( and I enable rc-local.service):

# Sanity check on required folders
if [ ! -x /var/log/mythtv ]; then
# make logging folder
mkdir -p -m 755 /var/log/mythtv
chown -hR mythtv:mythtv /var/log/mythtv
fi
# make pid folder
mkdir -p -m 755 /var/run/mythtv
chown -hR mythtv:mythtv /var/run/mythtv

(Besides the 'stabilized hardware and naming problems' referred to in
the wiki, the mythtv user has to be able to access the hardware too, so a
chown -R mythtv:mythtv /dev/dvb
or similar can obviate a problem appearing later on.)

Regarding the pidfile: mythtv 0.25 now also creates a mythlogserver
process which has its own pid, so creating a pidfile to avoid confusion
seems helpful. Also for that reason, I use type forking (although
otherwise the same setup as for simple) to alert systemd to the
situation. It then creates a group for the processes and keeps track of
things. You will see this in 'systemctl status' report

On both Fedora 16 and 17, systemd seems to have problems creating
folders in /run. And since /run gets created on every boot this can be a
blocker. The /run/mythtv folder just does not get created. As a result,
I have been using --pidfile /var/log/mythtv/backend.pid

HTH

Geoff

PS. I edited the wiki page to fix the formatting.




I have also found the systemd sometimes fails to create



_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


newbury at mandamus

Jul 10, 2012, 8:37 AM

Post #9 of 10 (504 views)
Permalink
Re: systemctl [In reply to]

On 07/10/2012 09:37 AM, Richard Shaw wrote:
> On Tue, Jul 10, 2012 at 8:29 AM, James Linder<jam [at] tigger> wrote:
>> G'day all
>>
>> I'm going crazy trying to start mythbackend using systemctrl
>>
>> If anybody can help --- pretty please ...
>>
>> Got the (fedora) systemctl file from the wiki: http://www.mythtv.org/wiki/Systemd_mythbackend_Configuration
>
> Whoops!!! Looks like there's an error in the wiki version!
>
> Just so anyone having this issue hopefully finds this thread I'll
> explain it in full again... (in other words, this is not directed at
> you, James)
>
> There are many options for how to run mythbackend with SystemD but
> one decision you
>
> *MUST*
> *MUST*
> *MUST*
>
> make is if you're going to run:
>
> Type=simple
>
> or
>
> Type=forking
>
> If you use Type=simple (which is my recommendation) then you *CANNOT*
> use the "--daemon" option because SystemD is not expecting the daemon
> to fork!!!
>
> If you use Type=forking then you *MUST* use the "--daemon" option as
> well as specify a PID file, "--pidfile" in ExecStart *AND* you must
> set the PIDFile= systemd option so it knows where to find the PID
> file.
>
> Someone please fix the wiki!

Fixed. Minor formatting errors corrected and explanation of the required
changes between simple and forking, added, plus additional information
about permissions problem correction.

Geoff




_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


newbury at mandamus

Jul 10, 2012, 8:38 AM

Post #10 of 10 (505 views)
Permalink
Re: systemctl [In reply to]

On 07/10/2012 10:02 AM, Richard Shaw wrote:
> Ok, now that my frustration has subsided :) Here's my recommended
> update to the service file on the wiki. This is an update of the
> version I package for Fedora...
>
> --- mythbackend.service ---
> # Do not edit this file, it will be replaced on update
> # If you need to make modifications to this unit file first make a copy in
> # /etc/systemd/system
>
> # This file is part of the packaging of MythTV
> #
> # MythTV is free software; view http://www.mythtv.org
> # for more information.
> #
> # It is sometimes necessary to wait for a capture
> # device to finish (hot)plug initialization before
> # the backend starts. If this is necessary,
> # create a Wants and After entry for all the capture
> # devices that one wishes to wait to be created
> # before the backend starts using the systemd
> # device name mangling names (/dev/some/thing turns
> # into dev-some-thing.device). These normally should
> # be udev persistent filename rules to avoid confusion.
> # See the MythTV wiki for udev persistent filename
> # discussions found at:
> # http://www.mythtv.org/wiki/Device_Filenames_and_udev
> #
> # In order to insure that systemd will create a
> # device unit for the capture device, one must
> # insure that udev will have the tag "systemd"
> # (i.e. add TAG+="systemd" to the udev rule).
> #
> # The MythTV package ships with a default udev
> # rule file located in: /lib/udev/rules.d/99-mythbackend.rules
>
> [Unit]
> Description=MythTV backend service
> After=network.target mysqld.service
> # Uncomment the following line if you will be using the mythweb plugin on the
> # same system as mythbackend.
> #Wants=httpd.service
>
> [Service]
> # Type=simple is recommended. If using Type=forking you will need to specify a
> # pidfile so systemd knows how to find the forked process PID, otherwise it
> # presumes that the process being started will be the remaining process.
> #Type=forking
> Type=simple
>
> Environment=MYTHCONFDIR=/etc/mythtv
> # Default setting assumes a system wide install. Otherwise it should be set to
> # the folder containing the .mythtv subfolder containing the config.xml file
> Environment=HOME=/usr/share/mythtv
>
> # systemd changes execution from the calling user (possibly root) to this user
> # if you have permissions problems or obscure errors try logging in as mythtv
> User=mythtv
>
> # Uncomment one of the following...
> # Use sysloging rather than separate logging:
> #ExecStart=/usr/bin/mythbackend --syslog local7
> # If Type=forking is set you must specify the --daemon and --pidfile options:
> #ExecStart=/usr/bin/mythbackend --daemon --logpath /var/log/mythtv
> --loglevel crit --pidfile /run/mythbackend.pid
> # Default setting for Type=simple.
> ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv
>
> # Whether systemd will continue over-watch and restart on any halt
> #Restart=Restart-always
>
> [Install]
> WantedBy=multi-user.target
> --- end ---

I added a lot more explanatory comments.

Geoff
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users

MythTV users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.