Bug 26026 - redshift does not start as a service, but does from command line.
Summary: redshift does not start as a service, but does from command line.
Status: NEW
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 7
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: Jani Välimaa
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-06 20:39 CET by Marc Krämer
Modified: 2020-01-18 03:10 CET (History)
1 user (show)

See Also:
Source RPM: redshift-1.12-3.mga7.src.rpm
CVE:
Status comment:


Attachments

Description Marc Krämer 2020-01-06 20:39:11 CET
starting redshift via systemd always fails:
-bash-4.4# systemctl start redshift
-bash-4.4# systemctl status redshift
● redshift.service - Redshift display colour temperature adjustment
   Loaded: loaded (/usr/lib/systemd/system/redshift.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2020-01-06 20:37:30 CET; 5s ago
     Docs: http://jonls.dk/redshift/
  Process: 26184 ExecStart=/usr/bin/redshift (code=exited, status=1/FAILURE)
 Main PID: 26184 (code=exited, status=1/FAILURE)

Jan 06 20:37:30 localhost systemd[1]: redshift.service: Service RestartSec=100ms expired, scheduling restart.
Jan 06 20:37:30 localhost systemd[1]: redshift.service: Scheduled restart job, restart counter is at 5.
Jan 06 20:37:30 localhost systemd[1]: Stopped Redshift display colour temperature adjustment.
Jan 06 20:37:30 localhost systemd[1]: redshift.service: Start request repeated too quickly.
Jan 06 20:37:30 localhost systemd[1]: redshift.service: Failed with result 'exit-code'.
Jan 06 20:37:30 localhost systemd[1]: Failed to start Redshift display colour temperature adjustment.


Starting on command line works:
-bash-4.4# /usr/bin/redshift
Standortanbieter »geoclue2« wird versucht …
Anbieter »geoclue2« wird verwendet.
Methode »randr« wird benutzt.
Es wird gewartet, bis der anfängliche Standort verfügbar ist …
Standort: XX° N, YY° O
Comment 1 Lewis Smith 2020-01-06 21:26:14 CET
Thank you for reporting this.
 $ urpmq -l redshift         includes:
 /usr/bin/redshift
 /usr/lib/systemd/system/redshift.service

Assigning to wally as registered & active 'redshift' maintainer.

Assignee: bugsquad => jani.valimaa
Summary: redshift unit does not work => redshift does not start as a service, but does from command line.

Comment 2 Dave Hodgins 2020-01-06 22:44:06 CET
I don't think redshift should be run as a service as it needs to run owned by
the user running the desktop environment.

As it's not enabled by default I hadn't noticed that it has a service file,
which was not present when I first started using it under Mageia 1. I've
been using it since then with kde, then plasma as my primary desktop.

To run it, I first manually ran redshift-gtk which creates
~/.config/autostart/redshift-gtk.desktop. I then enabled the desktop file
in systemsettings5, Workspace, Startup and Shutdown, Autostart.

I also created the config file as per the man page with ...
$ cat ~/.config/redshift.conf
; Global settings
[redshift]
temp-day=5000
temp-night=3000
transition=1
gamma=1.0
location-provider=manual
adjustment-method=vidmode

; The location provider and adjustment method settings
; are in their own sections.
[manual]
lat=42.9726
lon=-81.2382

; In this example screen 1 is adjusted by vidmode. Note
; that the numbering starts from 0, so this is actually
; the second screen.
[vidmode]
screen=0

CC: (none) => davidwhodgins

Comment 3 Marc Krämer 2020-01-06 22:54:30 CET
I've been using it for some time, but suddenly it was not started anymore, so I thought the "new" systemd files have replaced the startup in desktop.
I've removed my "old" redshift.desktop file which is not launched anymore (?). The new file is some different, haven't tested if this works now.


If this is the case, the systemd files should not be shipped.
Comment 4 Jani Välimaa 2020-01-08 19:37:53 CET
Systemd service files should work with --user. They were just at the wrong place.

Moved files from /usr/lib/systemd/system to /usr/lib/systemd/user in redshift-1.12-5.mga8.
Comment 5 Jani Välimaa 2020-01-08 20:05:25 CET
And as the issue was filed against mga7, the fix is also available in core/updates_testing for mga7.

SRPM:
redshift-1.12-3.1.mga7

RPMS:
redshift-1.12-3.1.mga7
redshift-common-1.12-3.1.mga7
redshift-gtk-1.12-3.1.mga7
Comment 6 Jani Välimaa 2020-01-08 22:39:05 CET
Updated pkgs in core/updates_testing adds also post/preun scriptlets for systemd user service files.

SRPM:
redshift-1.12-3.2.mga7

RPMS:
redshift-1.12-3.2.mga7
redshift-common-1.12-3.2.mga7
redshift-gtk-1.12-3.2.mga7
Comment 7 Dave Hodgins 2020-01-09 17:18:34 CET
Hasn't been assigned to qa yet, but I decided to test now anyway.

I disabled the autostart of redshift-gtk by plasma.

We need a way to ensure users know that each user who wants it, must run
$ systemctl --user enable redshift-gtk.service
and then either start the service or logout/in. A README.urpmi with this
info might be appropriate. Likewise with the redshift.service if the user
is not using redshift-gtk too.

At present, redshift-gtk is failing on Mageia 7 though due to a segfault.
From systemctl --user status redshift-gtk.service
Process: 3043 ExecStart=/usr/bin/redshift-gtk (code=dumped, signal=SEGV)

On this install, I use run level 3 (multi-user.target) as my default.target,
and then manually run startx, to start whichever desktop environment I want.
Not sure at this point if that is why it's failing with the segfault. Will
test later on an install that uses run level 5 (graphical.target) as it's
default.target.

After enabling and starting redshift.service manually, it's working.
$ systemctl --user status redshift.service
● redshift.service - Redshift display colour temperature adjustment
   Loaded: loaded (/usr/lib/systemd/user/redshift.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-01-09 10:31:27 EST; 9min ago
     Docs: http://jonls.dk/redshift/
 Main PID: 4040 (redshift)
   CGroup: /user.slice/user-500.slice/user@500.service/redshift.service
           └─4040 /usr/bin/redshift

Jan 09 10:31:27 x3.hodgins.homeip.net systemd[2754]: Started Redshift display colour temperature adjustment.
Jan 09 10:31:27 x3.hodgins.homeip.net redshift[4040]: Waiting for initial location to become available...
Jan 09 10:31:27 x3.hodgins.homeip.net redshift[4040]: Location: 42.97 N, 81.24 W

After a reboot, I manually have to start the service after starting plasma,
as it fails 5 times in between the login and the manual running of startx.
As most run level 3 users are advanced users, it's ok if we have to use
a workaround to ensure it's started after plasma starts, but it would be
nice if the startup could handle this situation too.

The redshift-gtk segfault must be fixed. A README or other documentation
explaining the change in the startup method should be added, and it would
be nice if easier support for run level 3 users could be added.
Comment 8 Dave Hodgins 2020-01-09 17:50:20 CET
I added RestartSec=30 to the [Service] section of /usr/lib/systemd/user/redshift.service and that works for me. The journal shows ...
Jan 09 11:46:03 systemd[2732]: redshift.service: Service RestartSec=30s expired, scheduling restart.
Jan 09 11:46:03 systemd[2732]: redshift.service: Scheduled restart job, restart counter is at 1.
Jan 09 11:46:03 systemd[2732]: Stopped Redshift display colour temperature adjustment.
Jan 09 11:46:03 systemd[2732]: Started Redshift display colour temperature adjustment.
Jan 09 11:46:03 redshift[3845]: Waiting for initial location to become available...
Jan 09 11:46:03 redshift[3845]: Location: 42.97 N, 81.24 W
Comment 9 Dave Hodgins 2020-01-09 19:43:11 CET
As expected, switching to using sddm to start plasma has no effect.
redshift-gtk still segfaults. Other then the .service files, what else
was changed?
Comment 10 Jani Välimaa 2020-01-10 18:00:53 CET
I had no problems with fresh install from core/udpates_testing in mga7 with Xfce. Redshift appeared to tray after reboot.

%post systemd macros seems to handle currently only fresh pkg installation and not updates.
Comment 11 Jani Välimaa 2020-01-10 18:06:17 CET
(In reply to Dave Hodgins from comment #7)
> 
> On this install, I use run level 3 (multi-user.target) as my default.target,
> and then manually run startx, to start whichever desktop environment I want.
> Not sure at this point if that is why it's failing with the segfault.

Does startx call /etc/X11/xinit/xinitrc.d/*.sh files, especially 50-systemd-user.sh, to set $DISPLAY? It's needed for redshift.

What's the output of 'systemctl --user show-environment'?
Comment 12 Dave Hodgins 2020-01-10 18:56:29 CET
$ systemctl --user show-environment
HOME=/home/dave
LANG=en_CA.UTF-8
LC_ADDRESS=en_CA.UTF-8
LC_COLLATE=en_CA.UTF-8
LC_CTYPE=en_CA.UTF-8
LC_IDENTIFICATION=en_CA.UTF-8
LC_MEASUREMENT=en_CA.UTF-8
LC_MESSAGES=en_CA.UTF-8
LC_MONETARY=en_CA.UTF-8
LC_NAME=en_CA.UTF-8
LC_NUMERIC=en_CA.UTF-8
LC_PAPER=en_CA.UTF-8
LC_TELEPHONE=en_CA.UTF-8
LC_TIME=en_DK.UTF-8
LOGNAME=dave
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
SHELL=/bin/bash
USER=dave
XDG_RUNTIME_DIR=/run/user/500
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/500/bus
DISPLAY=:0
XAUTHORITY=/home/dave/.Xauthority
Comment 13 Dave Hodgins 2020-01-11 21:02:35 CET
Pretty sure the problem is due to something I've done on my system.
It appears more than one copy of redshift is trying to run, causing the
problem.

While I'm currently running plasma, I have all desktop environments installed,
and have redshift autostart set up in each of those that support autostart.

I've disabled the autostart in plasma, but something is still starting it,
and clearly it doesn't handle having more than one copy running.

Unfortunately all of my test installs have redshift already set up, so I'll
have to do another install to test it properly.
Comment 14 Jani Välimaa 2020-01-15 17:38:49 CET
Added two patches:
1. Don't start both redshift and redshift-gtk service
2. Wait 5 secs before trying to restart systemd services

SRPM:
redshift-1.12-3.3.mga7

RPMS:
redshift-1.12-3.3.mga7
redshift-common-1.12-3.3.mga7
redshift-gtk-1.12-3.3.mga7
Comment 15 Dave Hodgins 2020-01-18 03:10:55 CET
Seems to be working ok. I did notice that with redshift-gtk, left clicking on
it's icon shows that it has it's own Autostart checkbox, which luckily appears
to no longer have any impact.

This bug has to be assigned to qa before the update can be validated.

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