Bug 754600 - Provide native systemd service
Summary: Provide native systemd service
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: boinc-client
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Milos Jakubicek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 751869
TreeView+ depends on / blocked
 
Reported: 2011-11-16 23:05 UTC by Jóhann B. Guðmundsson
Modified: 2012-03-12 18:23 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-08 14:23:39 UTC


Attachments (Terms of Use)
Native systemd service file for boinc-client (340 bytes, text/plain)
2011-11-16 23:06 UTC, Jóhann B. Guðmundsson
no flags Details
Native systemd service for boinc-client (367 bytes, text/plain)
2011-12-23 12:46 UTC, Jóhann B. Guðmundsson
no flags Details
Native systemd service for boinc-client (299 bytes, text/plain)
2011-12-23 15:22 UTC, Jóhann B. Guðmundsson
no flags Details

Description Jóhann B. Guðmundsson 2011-11-16 23:05:08 UTC
Description of problem:

Let's get the ball rolling on this one...

http://fedoraproject.org/wiki/Features/SysVtoSystemd
https://fedoraproject.org/wiki/Packaging:Guidelines:Systemd
https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Jóhann B. Guðmundsson 2011-11-16 23:06:53 UTC
Created attachment 534124 [details]
Native systemd service file for boinc-client

Comment 2 GuL 2011-12-22 22:15:46 UTC
Hello,
Thank you for this very good job. I was trying to do it by myself but unsuccessfully. This script is working fine on my system.

However, there's still a problem : if you want to compute boinc projects with the graphic card, using cuda for instance, the graphic card is not recognized after a reboot, unless you restart the service manually.

Origin of the problem : to have the graphic card recognized by boinc, the display manager should fully work before the start of the service. In the present script, it is only launched after the network.

Solution tested : After=prefdm.service --> boinc was lauched but still too early

Installation procedure :
1) save file into /etc/systemd/user/boinc-client.service
2) systemctl enable /etc/systemd/user/boinc-client.service

Equipment :
Fedora 16 64 bits
Intel Q8200
4 Go RAM
Nvidia 8400 GS

Do you have an idea ? Many thanks
GuL

NB : GPU computing can also cause alerts with SElinux, but it's working fine here

Comment 3 Jóhann B. Guðmundsson 2011-12-23 00:30:10 UTC
(In reply to comment #2)
> Hello,
> Thank you for this very good job. I was trying to do it by myself but
> unsuccessfully. This script is working fine on my system.
> 
> However, there's still a problem : if you want to compute boinc projects with
> the graphic card, using cuda for instance, the graphic card is not recognized
> after a reboot, unless you restart the service manually.

Change the [Install] line from...

WantedBy=multi-user.target

To 

WantedBy=graphical.target

In the submitted unit file and see if that does not solve your issue.

Comment 4 Jóhann B. Guðmundsson 2011-12-23 00:38:14 UTC
(In reply to comment #2)

> NB : GPU computing can also cause alerts with SElinux, but it's working fine
> here

Just file a report with the avc msg against selinux policy and Dan will fix that or help you fix that in your package.

Oh and uhum does systemctl reload boinc-client.service work as intended?

Comment 5 GuL 2011-12-23 10:22:39 UTC
(In reply to comment #3)
> Change the [Install] line from...
> WantedBy=multi-user.target
> To 
> WantedBy=graphical.target
> In the submitted unit file and see if that does not solve your issue.

Here is the result of 
After=prefdm.service
WantedBy=graphical.target

[guillaume@gul ~]$ service boinc-client status
cgset: the group can't be modified
boinc-client.service - Berkeley Open Infrastructure Network Computing Client
	  Loaded: loaded (/etc/systemd/user/boinc-client.service; enabled)
	  Active: active (running) since Fri, 23 Dec 2011 10:13:50 +0100; 1min 18s ago
	Main PID: 1164 (boinc_client)
	  CGroup: name=systemd:/system/boinc-client.service
		  ├ 1164 /usr/bin/boinc_client --dir /var/lib/boinc
		  ├ 1180 ../../projects/einstein.phys.uwm.edu/hsgamma_FGRP1...
		  ├ 1182 ../../projects/einstein.phys.uwm.edu/hsgamma_FGRP1...
		  ├ 1184 ../../projects/einstein.phys.uwm.edu/einsteinbinar...
		  └ 1186 ../../projects/einstein.phys.uwm.edu/hsgamma_FGRP1...

[guillaume@gul ~]$ service prefdm status
Redirecting to /bin/systemctl  status prefdm.service
prefdm.service - Display Manager
	  Loaded: loaded (/lib/systemd/system/prefdm.service; static)
	  Active: active (running) since Fri, 23 Dec 2011 10:13:50 +0100; 1min 26s ago
	Main PID: 1163 (gdm-binary)
	  CGroup: name=systemd:/system/prefdm.service
		  ├ 1163 /usr/sbin/gdm-binary -nodaemon
		  ├ 1171 /usr/libexec/gdm-simple-slave --display-id /org/gn...
		  ├ 1178 /usr/bin/Xorg :0 -background none -verbose -auth /...
		  └ 1383 /usr/bin/gnome-keyring-daemon --daemonize --login

Prefdm is launched before boinc but its children are not. Maybe do we need to wait until gnome-keyring-daemon is started ? Is there a way to do this ? Perhaps by adding a sleep 10 ?

Comment 6 GuL 2011-12-23 10:34:03 UTC
(In reply to comment #4)
> Just file a report with the avc msg against selinux policy and Dan will fix
> that or help you fix that in your package.

When I installed Fedora 16 from zero, I had alerts on /dev/nvidiactl and I added the following selinux policy :
allow boinc_t xserver_misc_device_t:chr_file { ioctl open };
allow boinc_t xserver_misc_device_t:chr_file { read write };

Now with selinux-policy-3.10.0-67.fc16 it seems to work without any alert and no boinc module present with selinux -l. --> OK

> Oh and uhum does systemctl reload boinc-client.service work as intended?
All right

Comment 7 Jóhann B. Guðmundsson 2011-12-23 11:11:26 UTC
Not following why/what the dependency is on Gnome-Keyring afaik GNOME Keyring is integrated with the user's login and it does not unlock anything until the user actually logs in could you explain it a bit further what the problem is here so I can better understand what we are racing with and what about KDE XFCE LXDE? 

Remove what ever you have added there ( like After=prefdm and I think it's safe to drop the network.target from there as well ) and just try this one.

[Unit]
Description=Berkeley Open Infrastructure Network Computing Client
After=graphical.target

[Service]
Nice=10
User=boinc
CPUShares=2
ControlGroup=cpu:/background
ExecStart=/usr/bin/boinc_client --dir /var/lib/boinc
ExecReload=/usr/bin/boinccmd --read_cc_config | sed -e "s/retval.*//" -e "N;s/\n//;

[Install]
WantedBy=graphical.target

Comment 8 Jóhann B. Guðmundsson 2011-12-23 11:25:51 UTC
Here's the unit with sleep added as you suggested but having to add it feels kinda hackish... 

[Unit]
Description=Berkeley Open Infrastructure Network Computing Client
After=graphical.target

[Service]
Nice=10
User=boinc
CPUShares=2
ControlGroup=cpu:/background
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/boinc_client --dir /var/lib/boinc
ExecReload=/usr/bin/boinccmd --read_cc_config | sed -e "s/retval.*//" -e
"N;s/\n//;

[Install]
WantedBy=graphical.target

Comment 9 GuL 2011-12-23 12:15:45 UTC
After=graphical.target
WantedBy=graphical.target
No sleep
--> boinc-client PID=1151-1179, prefdm PID=1155-1373, GPU unrecognized

After=graphical.target
WantedBy=graphical.target
ExecStartPre=/bin/sleep 10, PID=1139
--> boinc-client PID=1340-1447, prefdm PID=1141-1352, GPU OK

(In reply to comment #7)
> Not following why/what the dependency is on Gnome-Keyring afaik GNOME Keyring
> is integrated with the user's login and it does not unlock anything until the
> user actually logs in could you explain it a bit further what the problem is
> here so I can better understand what we are racing with and what about KDE XFCE
> LXDE? 

If I correctly understand, prefdm launches X11 wich initializes the display driver needed to recognize the GPU. When graphical or prefdm report completion, the driver is not initialized so the GPU is unrecognized.

Maybe 10s is too much, I am trying with 1 or 3s.

Comment 10 Jóhann B. Guðmundsson 2011-12-23 12:26:44 UTC
(In reply to comment #2)
> Hello,
> Thank you for this very good job. I was trying to do it by myself but
> unsuccessfully. This script is working fine on my system.
> 
> However, there's still a problem : if you want to compute boinc projects with
> the graphic card, using cuda for instance, the graphic card is not recognized
> after a reboot, unless you restart the service manually.

This comes on as a bit odd either what cuda is doing or boinc is doing is buggy/broken.

> 
> Origin of the problem : to have the graphic card recognized by boinc, the
> display manager should fully work before the start of the service.

How does boinc detect the graphics card as in why do you have to restart boinc to detect the graphics card/cuda?

Does this work as advertised if you are not using cuda ? 

Is cuda started in some special way for example started by a script which could not be fully initialized when boinc is started?

Comment 11 GuL 2011-12-23 12:30:09 UTC
sleep 1 is ok, pb solved, thanks a lot.

One more thing : prefdm is freezing sometimes. I need to restart it from the
console. It was not the case before this script, and that's not due to the GPU
computing as it is off when I am active and with a project that stop crunching
immediately on demand (primegrid).

If you need additional tests please tell me.

Comment 12 GuL 2011-12-23 12:44:24 UTC
(In reply to comment #10)
> This comes on as a bit odd either what cuda is doing or boinc is doing is
> buggy/broken.

I don't think so : it's working fine when the driver is previously initialized

> How does boinc detect the graphics card as in why do you have to restart boinc
> to detect the graphics card/cuda?

I suppose that boinc don't address the nvidia driver itself but is speaking through X11. If X11 is not ready, boinc can't access the gpu and just report it is absent. That's the same if the drivers are not properly installed nor the cuda toolkit.

> Does this work as advertised if you are not using cuda ? 

Yes, no problem

> Is cuda started in some special way for example started by a script which could
> not be fully initialized when boinc is started?

No, but you need to install it separately with this protocol :

# Cuda
# http://developer.nvidia.com/cuda-toolkit-40
wget http://www.nvidia.com/object/thankyou.html?url=/compute/cuda/4_0/toolkit/cudatoolkit_4.0.17_linux_64_fedora13.run
chmod u+x cudatoolkit_4.0.17_linux_64_fedora13.run
./cudatoolkit_4.0.17_linux_64_fedora13.run

# Path update
# /etc/profile.d/cuda.sh
PATH=$PATH:/usr/local/cuda/bin
# /etc/ld.so.conf.d/cuda-x86_64.conf
/usr/local/cuda/lib64
/usr/local/cuda/lib

Comment 13 Jóhann B. Guðmundsson 2011-12-23 12:46:02 UTC
Created attachment 549338 [details]
Native systemd service for boinc-client

Fixes based on feed back

Comment 14 Jóhann B. Guðmundsson 2011-12-23 13:03:54 UTC
(In reply to comment #11)
> sleep 1 is ok, pb solved, thanks a lot.
> 
> One more thing : prefdm is freezing sometimes. I need to restart it from the
> console. It was not the case before this script

By script you mean the systemd unit as in the boinc-client.service or are you using some script?

, and that's not due to the GPU
> computing as it is off when I am active and with a project that stop crunching
> immediately on demand (primegrid).

Check logs .xsession errors for the user xorg and messages log files in /var/log 

Something should be saying something without knowing what causes the freeze there is not much that can be done.

The prefdm service is set to restart always in the unit 

"
Restart=always
RestartSec=0"

If set to always the service will be restarted regardless whether it exited cleanly or not, or got terminated abnormally by a signal.

I'm pretty sure this might effect cuda and or the boinc client if prefdm suddenly is restarted. 

You are probably hitting some X bug here

Comment 15 GuL 2011-12-23 13:24:30 UTC
(In reply to comment #14)
> By script you mean the systemd unit as in the boinc-client.service or are you
> using some script?

boinc-client.service only

> Check logs .xsession errors for the user xorg and messages log files in
> /var/log 

nothing evident in the logs. I will check if it happens again

> You are probably hitting some X bug here

maybe, but it is almost not present, so that's not so disturbing

Comment 16 Jóhann B. Guðmundsson 2011-12-23 13:33:09 UTC
Can you try this one and boot into multi-user target just add 3 to the kernel
commmand line in grub 

I'm hoping that it solves starting the service when you dont boot into
graphical target ( runlevel 3 ) as well as work when you boot into
graphical.target ( runlevel 5 ) 

And solves "we do not want to start boinc after X server (for CPU computing it
does not make sense, it should be enough that you power on the machine)."
comment 3 in bug 719878.

As it is now the unit would only be started in graphical mode

[Unit]
Description=Berkeley Open Infrastructure Network Computing Client
After=network.target graphical.target

[Service]
Nice=10
User=boinc
CPUShares=2
ControlGroup=cpu:/background
ExecStartPre=/bin/sleep 1
ExecStart=/usr/bin/boinc_client --dir /var/lib/boinc
ExecReload=/usr/bin/boinccmd --read_cc_config | sed -e "s/retval.*//" -e "N;s/\n//;

[Install]
WantedBy=multi-user.target

Comment 17 Jóhann B. Guðmundsson 2011-12-23 13:38:45 UTC
and I'm pretty sure that the reload command is not working as expected since we are piping it into sed

Comment 18 GuL 2011-12-23 14:23:56 UTC
(In reply to comment #16)
> And solves "we do not want to start boinc after X server (for CPU computing it
> does not make sense, it should be enough that you power on the machine)."
> comment 3 in bug 719878.

It works without gpu in runlevel 3 and with gpu in runlevel 5

(In reply to comment #17)
> and I'm pretty sure that the reload command is not working as expected since we
> are piping it into sed

You're right : there is no error but the parameters are not reloaded. Is it really useful ? We can simply do a restart. And what about the CPUShares=2
line ? What happens if there is only one CPU or more than 2 ?

Comment 19 Jóhann B. Guðmundsson 2011-12-23 15:17:17 UTC
(In reply to comment #18)
> (In reply to comment #16)
> > And solves "we do not want to start boinc after X server (for CPU computing it
> > does not make sense, it should be enough that you power on the machine)."
> > comment 3 in bug 719878.
> 
> It works without gpu in runlevel 3 and with gpu in runlevel 5
> 
> (In reply to comment #17)
> > and I'm pretty sure that the reload command is not working as expected since we
> > are piping it into sed
> 
> You're right : there is no error but the parameters are not reloaded. Is it
> really useful ? We can simply do a restart. And what about the CPUShares=2
> line ? What happens if there is only one CPU or more than 2 ?

These are cpu time shares ( cgroup resources ) not the amount of cpu's and cores and it set to 2 as in receive twice the CPU time of tasks in a control group where cpu shares is set to 1.

see
http://docs.fedoraproject.org/en-US/Fedora/16/html/Resource_Management_Guide/ch01.html
http://www.kernel.org/doc/Documentation/cgroups/
http://people.redhat.com/mingo/cfs-scheduler/sched-design-CFS.txt

Comment 20 Jóhann B. Guðmundsson 2011-12-23 15:22:52 UTC
Created attachment 549358 [details]
Native systemd service for boinc-client

Drop the reload command and fixed the service to start in multi-user target as well as graphical.target

Comment 21 GuL 2011-12-23 15:40:07 UTC
Ok, great, have a merry christmas

Comment 22 Milos Jakubicek 2012-02-08 14:23:39 UTC
Hello guys,

thanks a lot for your work and sorry for not getting back earlier. I just built boinc-client for F17/F18 using the provided systemd unit.

Milos

Comment 23 GuL 2012-03-12 18:23:38 UTC
Many thanks Milos



Hello Johann,
Something is strange : the systemd service has been working well for a long time, is still working in runlevel 3, but not anymore in runlevel 5, since probably an update, on the same computer.

systemctl status indicates that the service is enabled, launched but dead. If I restart it manually it works fine. If I use the init.d script instead, it starts. 

I tried also unsuccessfully to add the following lines in the service section of the systemd file
Restart=always
RestartSec=1

linux 3.2.9-1.fc16.x86_64
boinc-client.x86_64 6.12.35-1.r24014svn.fc16
selinux-policy.noarch 3.10.0-75.fc16

Any ideas ?
Cheers


Note You need to log in before you can comment on or make changes to this bug.