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

Mailing List Archive: MythTV: Users

Systemd File For MythTV on Fedora Questions

 

 

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


george.galt at gmail

May 14, 2012, 7:40 AM

Post #1 of 11 (1201 views)
Permalink
Systemd File For MythTV on Fedora Questions

All:

I've been working on a .service script for the mythbackend on systemd
for my Fedora 16 x86_64 backend, which is installed using Axel's
ATrpms repositories. The script so far is below and owes a lot to the
discussion last week. Currently, this file works for me.

I've got a few questions that I'm hoping someone can answer:

1) Permissions. The script below runs the backend as user "mythtv"
rather than "root". I've set permissions for the directories
containing the recordings/videos, coverart (etc), logs, database
backup, and pid file to user=mythtv, but is there anything else that I
might be missing or anything that I should look out for? So far, this
seems to work, but if there is something that is run infrequently I
might not have seen it yet.

2) service type. The RPMfusion script and the script on the mythtv
wiki designate the service as "type=simple". RG Newbury's version
(from last week's discussion) used "type=forking". I find that if I
try to use "type=simple" the startup fails with "systemd[1]:
mythbackend.service stopping timed out. Killing." in
/var/log/messages. Does anyone know why this might be? I find the
description here:
http://fedoraproject.org/wiki/Packaging:Systemd#.5BService.5D to be
unhelpful.

Thanks,

George



###################################################
# file located at /lib/systemd/system/mythbackend.service
# use "systemctl enable mythtbackend.service to load
# based on a template from RPMFusion and R.G. Newbury from this thread:
# http://www.gossamer-threads.com/lists/mythtv/users/516650?search_string=mythbackend.service%20;#516650

[Unit]
Description=MythTV backend service

After=network.target mysqld.service
# for mythweb: not necessary so 'wants' not 'after'
Wants=httpd.service

[Service]
Type=forking
# Both the RPMFusion version and the verion on
http://www.mythtv.org/wiki/Systemd_mythbackend_Configuration
# use "Type=simple", but I find that it does not seem to work and one
gets a bunch of permission errors.
# It is possible that someone who knew the permissioning schemes
better could return to using "Type=simple"

# description: mythbackend.
# processname: mythbackend
# pidfile: /var/log/mythtv/mythbackend.pid
# NOTE: location of pid file is different from the location used
# by the SysVInit service, which used to place the pid file in /var/run
# because we are running as the mythtv user,

Environment=MYTHTV_HOME=/var/lib/mythtv
Environment=MYTHCONFDIR=/var/lib/mythtv
Environment=HOME=/var/lib/mythtv
# NOTE: using the "mythtv" user, NOT root.
User=mythtv
EnvironmentFile=/etc/sysconfig/mythbackend

# NOTE: if you have other switches you want, insert them below. This
is set to use log files in
# /var/log/mythtv. Make sure that the location of the HOME/MYTHCONFIG
files, logs and the pid file
# are writeable by the user designated above.
ExecStart=/usr/bin/mythbackend --daemon --logpath /var/log/mythtv
--pidfile /var/log/mythtv/mythbackend.pid

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


hobbes1069 at gmail

May 14, 2012, 7:51 AM

Post #2 of 11 (1178 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

On Mon, May 14, 2012 at 9:40 AM, George Galt <george.galt [at] gmail> wrote:
> All:
>
> I've been working on a .service script for the mythbackend on systemd
> for my Fedora 16 x86_64 backend, which is installed using Axel's
> ATrpms repositories.  The script so far is below and owes a lot to the
> discussion last week.  Currently, this file works for me.
>
> I've got a few questions that I'm hoping someone can answer:
>
> 1)  Permissions.  The script below runs the backend as user "mythtv"
> rather than "root".  I've set permissions for the directories
> containing the recordings/videos, coverart (etc), logs, database
> backup, and pid file to user=mythtv, but is there anything else that I
> might be missing or anything that I should look out for?  So far, this
> seems to work, but if there is something that is run infrequently I
> might not have seen it yet.

It has not been necessary to run mythbackend as root for quite some
time. Just make sure the mythtv user is in the audio and video groups
for access to those devices.

It shouldn't be necessary to change permissions on the physical
database since mythtv logs in through the server interface.
Additionally, you don't need to worry about the PID file if you use
Type=simple, see below.


> 2)  service type.  The RPMfusion script and the script on the mythtv
> wiki designate the service as "type=simple".  RG Newbury's version
> (from last week's discussion) used "type=forking".  I find that if I
> try to use "type=simple" the startup fails with "systemd[1]:
> mythbackend.service stopping timed out. Killing." in
> /var/log/messages.  Does anyone know why this might be?  I find the
> description here:
> http://fedoraproject.org/wiki/Packaging:Systemd#.5BService.5D to be
> unhelpful.

If you use "Type=simple" then you need to drop the --daemon options.
Simple is preferred over forking in systemd. Basically systemd picks
up the PID when it starts the backend. If you use --daemon then
mythbackend forks so then you have to use a PID file.


> Environment=MYTHTV_HOME=/var/lib/mythtv
> Environment=MYTHCONFDIR=/var/lib/mythtv
> Environment=HOME=/var/lib/mythtv
> # NOTE: using the "mythtv" user, NOT root.
> User=mythtv
> EnvironmentFile=/etc/sysconfig/mythbackend

Using both the Environment and EnvironmentFile options is redundant.
EnvrionmentFile is more for backwards compatibility, so drop that in
favor of Environment.


> ExecStart=/usr/bin/mythbackend --daemon --logpath /var/log/mythtv
> --pidfile /var/log/mythtv/mythbackend.pid

To use Type=simple, drop the --daemon and --pidfile options.

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


newbury at mandamus

May 14, 2012, 8:15 AM

Post #3 of 11 (1173 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

On 05/14/2012 10:40 AM, George Galt wrote:
> All:
>
> I've been working on a .service script for the mythbackend on systemd
> for my Fedora 16 x86_64 backend, which is installed using Axel's
> ATrpms repositories. The script so far is below and owes a lot to the
> discussion last week. Currently, this file works for me.
>
> I've got a few questions that I'm hoping someone can answer:
>
> 1) Permissions. The script below runs the backend as user "mythtv"
> rather than "root". I've set permissions for the directories
> containing the recordings/videos, coverart (etc), logs, database
> backup, and pid file to user=mythtv, but is there anything else that I
> might be missing or anything that I should look out for? So far, this
> seems to work, but if there is something that is run infrequently I
> might not have seen it yet.
>
> 2) service type. The RPMfusion script and the script on the mythtv
> wiki designate the service as "type=simple". RG Newbury's version
> (from last week's discussion) used "type=forking". I find that if I
> try to use "type=simple" the startup fails with "systemd[1]:
> mythbackend.service stopping timed out. Killing." in
> /var/log/messages. Does anyone know why this might be? I find the
> description here:
> http://fedoraproject.org/wiki/Packaging:Systemd#.5BService.5D to be
> unhelpful.

1) I think you have covered all of the places which need to be chown'd.
I cannot think of any other spots.

2) I could never get type=simple to work. I had exactly your experience.
I think that simple disallows any ExecStartPre invocations. And since
there are permissions issues etc. I followed the example of the mysql
which runs both Pre and Post scripts to ensure that things "just work"
(the heavy lifting having been done behind the scenes.)

As to not using /var/run or /run, I found that the required folders were
*sometimes* not created (eg /var/run/mythtv), leading, of course to a
rather well disguised startup failure. Why, I have no idea. Systemd
*should* do that, but ofttimes would not. So pidfile=/var/log/mythtv
which will exist.

And as you say, the 'help' is not very.

Geoff




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


george.galt at gmail

May 14, 2012, 8:15 AM

Post #4 of 11 (1174 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

On Mon, May 14, 2012 at 10:51 AM, Richard Shaw <hobbes1069 [at] gmail> wrote:
> On Mon, May 14, 2012 at 9:40 AM, George Galt <george.galt [at] gmail> wrote:
>> All:
>>
>> I've been working on a .service script for the mythbackend on systemd
>> for my Fedora 16 x86_64 backend, which is installed using Axel's
>> ATrpms repositories.  The script so far is below and owes a lot to the
>> discussion last week.  Currently, this file works for me.
>>
>> I've got a few questions that I'm hoping someone can answer:
>>
>> 1)  Permissions.  The script below runs the backend as user "mythtv"
>> rather than "root".  I've set permissions for the directories
>> containing the recordings/videos, coverart (etc), logs, database
>> backup, and pid file to user=mythtv, but is there anything else that I
>> might be missing or anything that I should look out for?  So far, this
>> seems to work, but if there is something that is run infrequently I
>> might not have seen it yet.
>
> It has not been necessary to run mythbackend as root for quite some
> time. Just make sure the mythtv user is in the audio and video groups
> for access to those devices.
>
> It shouldn't be necessary to change permissions on the physical
> database since mythtv logs in through the server interface.
> Additionally, you don't need to worry about the PID file if you use
> Type=simple, see below.
>
>
>> 2)  service type.  The RPMfusion script and the script on the mythtv
>> wiki designate the service as "type=simple".  RG Newbury's version
>> (from last week's discussion) used "type=forking".  I find that if I
>> try to use "type=simple" the startup fails with "systemd[1]:
>> mythbackend.service stopping timed out. Killing." in
>> /var/log/messages.  Does anyone know why this might be?  I find the
>> description here:
>> http://fedoraproject.org/wiki/Packaging:Systemd#.5BService.5D to be
>> unhelpful.
>
> If you use "Type=simple" then you need to drop the --daemon options.
> Simple is preferred over forking in systemd. Basically systemd picks
> up the PID when it starts the backend. If you use --daemon then
> mythbackend forks so then you have to use a PID file.
>
>
>> Environment=MYTHTV_HOME=/var/lib/mythtv
>> Environment=MYTHCONFDIR=/var/lib/mythtv
>> Environment=HOME=/var/lib/mythtv
>> # NOTE: using the "mythtv" user, NOT root.
>> User=mythtv
>> EnvironmentFile=/etc/sysconfig/mythbackend
>
> Using both the Environment and EnvironmentFile options is redundant.
> EnvrionmentFile is more for backwards compatibility, so drop that in
> favor of Environment.
>
>
>> ExecStart=/usr/bin/mythbackend --daemon --logpath /var/log/mythtv
>> --pidfile /var/log/mythtv/mythbackend.pid
>
> To use Type=simple, drop the --daemon and --pidfile options.
>
> Richard
> _______________________________________________
> mythtv-users mailing list
> mythtv-users [at] mythtv
> http://www.mythtv.org/mailman/listinfo/mythtv-users

Richard:

Thanks for the detailed comments!! I'll see if I can't put them into
practice tonight.

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


gary.buhrmaster at gmail

May 14, 2012, 9:16 AM

Post #5 of 11 (1176 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

On Mon, May 14, 2012 at 3:15 PM, R. G. Newbury <newbury [at] mandamus> wrote:
....
> As to not using /var/run or /run, I found that the required folders were
> *sometimes* not created

Some newer distros make /var/run or /run tmpfs filesystems,
so you need to use upstart's/systemd's tmpfiles.d/ mechanisms
(usually /etc/tmpfiles.d/)

Your distro will vary.

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


holists at verizon

May 14, 2012, 4:42 PM

Post #6 of 11 (1164 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

On Mon, 2012-05-14 at 09:51 -0500, Richard Shaw wrote:
> On Mon, May 14, 2012 at 9:40 AM, George Galt <george.galt [at] gmail> wrote:
<snip>
>
> It has not been necessary to run mythbackend as root for quite some
> time. Just make sure the mythtv user is in the audio and video groups
> for access to those devices.
>
> It shouldn't be necessary to change permissions on the physical
> database since mythtv logs in through the server interface.
> Additionally, you don't need to worry about the PID file if you use
> Type=simple, see below.
>
>
<snip>
>
> If you use "Type=simple" then you need to drop the --daemon options.
> Simple is preferred over forking in systemd. Basically systemd picks
> up the PID when it starts the backend. If you use --daemon then
> mythbackend forks so then you have to use a PID file.
>
>
> > Environment=MYTHTV_HOME=/var/lib/mythtv
> > Environment=MYTHCONFDIR=/var/lib/mythtv
> > Environment=HOME=/var/lib/mythtv
> > # NOTE: using the "mythtv" user, NOT root.
> > User=mythtv
> > EnvironmentFile=/etc/sysconfig/mythbackend
>
> Using both the Environment and EnvironmentFile options is redundant.
> EnvrionmentFile is more for backwards compatibility, so drop that in
> favor of Environment.
>
>
> > ExecStart=/usr/bin/mythbackend --daemon --logpath /var/log/mythtv
> > --pidfile /var/log/mythtv/mythbackend.pid
>
> To use Type=simple, drop the --daemon and --pidfile options.
>
> Richard
> _______________________________________________
> mythtv-users mailing list
> mythtv-users [at] mythtv
> http://www.mythtv.org/mailman/listinfo/mythtv-users

Richard,

This is related to this topic, so I hope you don't mind a little
thread-jacking :)

It seems you wrote the rpm packaging mods to support systemd. I tried
modifying build_myth.sh to enable systemd (adding --with systemd) and
got this error when mythtv.spec is built:

error: syntax error in expression
error: /home/mythtv/mythtv/0.25-fixes/packaging/rpm/mythtv.spec:159:
parseExpressionBoolean returns -1


This is the first instance of "%if %{with_systemd}" and I cannot figure
out how to address the error short of commenting out all of the "then"
clauses (so that systemd is the default for compile). I'm running
Fedora 16 (if that makes a difference). I cannot see how a value of -1
gets set if 0 and 1 are the only defined values (in the %define).

Any help would be greatly appreciated. TIA!


-- Harry O.


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


newbury at mandamus

May 14, 2012, 8:24 PM

Post #7 of 11 (1159 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

On 05/14/2012 12:16 PM, Gary Buhrmaster wrote:
> On Mon, May 14, 2012 at 3:15 PM, R. G. Newbury<newbury [at] mandamus> wrote:
> ....
>> As to not using /var/run or /run, I found that the required folders were
>> *sometimes* not created
>
> Some newer distros make /var/run or /run tmpfs filesystems,
> so you need to use upstart's/systemd's tmpfiles.d/ mechanisms
> (usually /etc/tmpfiles.d/)
>
> Your distro will vary.

Fedora 16 on the mythbox. Please explain a little more. I wasted a fair
bit of time trying to get ExecStartPre to actually create
/var/run/mythtv after a reboot. And failing for inexplicable reasons was
frustrating. I've never seen a mention of tmpfiles.d before.

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


gary.buhrmaster at gmail

May 14, 2012, 8:40 PM

Post #8 of 11 (1161 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

On Mon, May 14, 2012 at 8:24 PM, R. G. Newbury <newbury [at] mandamus> wrote:
....
> Fedora 16 on the mythbox. Please explain a little more. I wasted a fair bit
> of time trying to get ExecStartPre to actually create /var/run/mythtv after
> a reboot. And failing for inexplicable reasons was frustrating. I've never
> seen a mention of tmpfiles.d before.

Create a (new) file in /etc/tmpfiles.d/ called something like
mythbackend.conf with the contents something like
d /var/run/mythtv 0755 mythtv mythtv -
It should create a 'd'irectory /var/run/mythtv with
permissions 0755 owned by mythtv:mythtv at
startup. Adjust as needed for your config.

man tmpfiles.d for assistance.

Note that if you are a packager, you want to put
the files in /usr/lib/tmpfiles.d/ (the /etc/ directory
is for local overrides).
_______________________________________________
mythtv-users mailing list
mythtv-users [at] mythtv
http://www.mythtv.org/mailman/listinfo/mythtv-users


hobbes1069 at gmail

May 15, 2012, 6:00 AM

Post #9 of 11 (1150 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

Just a reminder... You don't need a PID file if you run Type=simple...
It really is easier!

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


george.galt at gmail

May 15, 2012, 6:29 AM

Post #10 of 11 (1147 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

On Tue, May 15, 2012 at 9:00 AM, Richard Shaw <hobbes1069 [at] gmail> wrote:
> Just a reminder... You don't need a PID file if you run Type=simple...
> It really is easier!
>
> Richard
> _______________________________________________
> mythtv-users mailing list
> mythtv-users [at] mythtv
> http://www.mythtv.org/mailman/listinfo/mythtv-users

Thanks everyone. I've got it working.

Here is the file I ended up with:

###################################################
# file located at /lib/systemd/system/mythbackend.service
# use "systemctl enable mythtbackend.service to load
# based on a template from RPMFusion and R.G. Newbury from this thread:
# http://www.gossamer-threads.com/lists/mythtv/users/516650?search_string=mythbackend.service%20;#516650

[Unit]
Description=MythTV backend service

After=network.target mysqld.service
# for mythweb: not necessary so 'wants' not 'after'
Wants=httpd.service

[Service]
Type=simple


Environment=MYTHTV_HOME=/var/lib/mythtv
Environment=MYTHCONFDIR=/var/lib/mythtv
Environment=HOME=/var/lib/mythtv
# NOTE: using the "mythtv" user, NOT root.
User=mythtv

# NOTE: if you have other switches you want, insert them below. This
is set to use log files in
# /var/log/mythtv. Make sure that the location of the HOME/MYTHCONFIG
files, logs and the pid file
# are writeable by the user designated above.
ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv

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


newbury at mandamus

May 15, 2012, 2:50 PM

Post #11 of 11 (1135 views)
Permalink
Re: Systemd File For MythTV on Fedora Questions [In reply to]

On 05/15/2012 09:00 AM, Richard Shaw wrote:
> Just a reminder... You don't need a PID file if you run Type=simple...
> It really is easier!
>
> Richard

Yes! Thanks for that Richard. I presume I was using contradictory
settings when I last played around with it. Likely the existence of
--daemon with or without the pidfile.

Your settings: Simple, use Environment, no daemon and no pidfile works
fine. AND it starts faster than the forking method. This is still with a
pre-start.sh and with everything pointing to /var/log/mythtv.

(And the 'test setup' on the desktop at work *proves its utility yet
again*!!!)

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.