[systemd-devel] systemd + ExecStart + python script

Abdelghani Ouchabane abdelghani at ezono.com
Tue Nov 12 09:14:30 PST 2013


On 11/11/13 17:32, Zbigniew Jędrzejewski-Szmek wrote:
> On Mon, Nov 11, 2013 at 04:55:05PM +0100, Abdelghani Ouchabane wrote:
>> ExecStart=/usr/bin/python /opt/cyclades/bin/t_idl.pyo
>>             |-1377 /bin/sh -c if [ ! -e
>> /home/x/taskconfig/screensaver ]; then /bin/mkdir -p
>> /home/x/taskconfig ;                        /bin/cp
>> /opt/cyclades/etc/taskconfig/screensaver
>> /home/x/taskconfig/screensaver ;                        fi ;
>> /bin/echo -n $BASHPID > /var/tmp/cyclades_services/IDL/pid ;
>> DISPLAY=:0 CYCLADES_ERR=IDL /opt/cyclades/bin/logger.sh -c
>> "/usr/bin/python /opt/cyclades/bin/t_idl.pyo" -p err -t IDL
> Those two don't correspond. Either you're starting the program
> directly, or through some shell scripts. It would help if you
> showed the two unit files.
>
> Zbyszek
>
>
Hallo Zbyszek,
   I modified the unit to start the main program as:

1- ExecStart=/bin/sh -c 'DISPLAY=:0 /usr/bin/python 
/opt/cyclades/bin/t_idl.pyo'

Results:
ezono-cyclades-t_idl.service - ezono-cyclades-t_idl Service
    Loaded: loaded 
(/usr/lib/systemd/system/ezono-cyclades-t_idl.service; static)
    Active: active (running) since Tue 2013-11-12 17:49:59 CET; 3min 16s ago
   Process: 1335 ExecStartPre=/bin/echo -n $BASHPID > 
/var/tmp/cyclades_services/IDL/pid (code=exited, status=0/SUCCESS)
   Process: 1316 ExecStartPre=/bin/sh -c if [ ! -e 
/home/x/taskconfig/screensaver ]; then /bin/mkdir -p /home/x/taskconfig 
; /bin/cp /opt/cyclades/etc/taskconfig/screensaver 
/home/x/taskconfig/screensaver ;                           fi 
(code=exited, status=0/SUCCESS)
  Main PID: 1378 (python)
    CGroup: name=systemd:/system/ezono-cyclades-t_idl.service
            `-1378 /usr/bin/python /opt/cyclades/bin/t_idl.pyo

Nov 12 17:50:05 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 17:50:07 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 17:50:07 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 17:50:08 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 17:50:08 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 17:50:09 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 17:50:11 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 17:50:11 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 17:50:25 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 17:52:23 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.

2- ExecStart=/bin/sh -c '/opt/run-t_idl.sh'

where:
/opt/run-t_idl.sh contains :  DISPLAY=:0 /usr/bin/python 
/opt/cyclades/bin/t_idl.pyo

Results:
ezono-cyclades-t_idl.service - ezono-cyclades-t_idl Service
    Loaded: loaded 
(/usr/lib/systemd/system/ezono-cyclades-t_idl.service; static)
    Active: active (running) since Tue 2013-11-12 18:07:18 CET; 9s ago
   Process: 1478 ExecStartPre=/bin/echo -n $BASHPID > 
/var/tmp/cyclades_services/IDL/pid (code=exited, status=0/SUCCESS)
   Process: 1449 ExecStartPre=/bin/sh -c if [ ! -e 
/home/x/taskconfig/screensaver ]; then /bin/mkdir -p /home/x/taskconfig 
; /bin/cp /opt/cyclades/etc/taskconfig/screensaver 
/home/x/taskconfig/screensaver ;                           fi 
(code=exited, status=0/SUCCESS)
  Main PID: 1550 (sh)
    CGroup: name=systemd:/system/ezono-cyclades-t_idl.service
            |-1550 /bin/sh -c /opt/run-t_idl.sh
            `-1556 /usr/bin/python /opt/cyclades/bin/t_idl.pyo

Nov 12 18:07:23 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 18:07:23 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 18:07:23 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 18:07:23 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 18:07:24 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 18:07:25 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 18:07:25 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 18:07:26 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 18:07:26 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.
Nov 12 18:07:28 sonostation-usb12-eth.ezono.net systemd[1]: Started 
ezono-cyclades-t_idl Service.



It looks that systemd doesn't track python script properly or my python 
script is doing something strange.


Regards
Ghani


More information about the systemd-devel mailing list