You are not logged in.

#1 2013-10-26 03:57:20

axelectrik
Member
Registered: 2012-01-25
Posts: 126

Restart automatically if application gets killed

I have this issue for two precise applications:
1. Mplayer - Wich I use as wallpaper but sometimes gets killed
2. Osdlyrics - It gest killed for no special reason (Seg fault)

I want to make a script so this applications be restarted in case they get killed, how could I track that and restart it?

Thank you smile

Offline

#2 2013-10-26 04:08:18

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Restart automatically if application gets killed

Write a service file...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2013-10-27 18:45:45

axelectrik
Member
Registered: 2012-01-25
Posts: 126

Re: Restart automatically if application gets killed

Great idea! But I've read million of times the https://wiki.archlinux.org/index.php/Sy … vice_files and to be honest I don't understand anything!
I don't get the "Types" or wich dependencies might this applications need.
Any help.. please big_smile

Offline

#4 2013-10-27 19:36:01

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Restart automatically if application gets killed

Read the systemd man pages.  I have found that their documentation (although not complete since new features are still being added) is quite good.  The stuff for systemd.unit files is generally very complete.  The only issue one might have in wading through those man pages is that the unit files are separated into a bunch of different systemd.* man pages.  But fortunately, there is the systemd.directives man page which can tell you where to find info on each configuration option... and more.

Offline

#5 2013-11-02 06:14:22

axelectrik
Member
Registered: 2012-01-25
Posts: 126

Re: Restart automatically if application gets killed

I did my best but I really don't get it sad
Problem after problem...
This is not explained very well in man nor in the wiki :S

Offline

#6 2013-11-02 06:16:48

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Restart automatically if application gets killed

What did you try? "Problem after problem" is not an error message.

Also, the documentation for systemd is above average, IMO.


/usr/lib/systemd/system/ is stuffed full of service files: copy one that is similar to what you need and start from there; it is not difficult.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2013-11-02 18:21:54

axelectrik
Member
Registered: 2012-01-25
Posts: 126

Re: Restart automatically if application gets killed

OK I'll show you what I have :

[Service]
Type=simple
ExecStart=/usr/bin/wallpaper
ExecStartPre=/usr/bin/xfdesktop
Restart=always

systemd status wallpaper.service throws:

wallpaper.service
   Loaded: loaded (/etc/systemd/system/wallpaper.service; static)
   Active: failed (Result: start-limit) since sáb 2013-11-02 12:10:38 CST; 11s ago
  Process: 13911 ExecStartPre=/usr/bin/xfdesktop (code=exited, status=1/FAILURE)
 Main PID: 1743 (code=exited, status=0/SUCCESS)

If I remove the line of xfdesktop the output shows as active but nothing is displaying

THis is my /usr/bin/wallpaper :

#!/bin/bash
WIND=$(xwininfo -name Escritorio | egrep -E '0x' | cut -d':' -f3 | cut -d'"' -f1| cut -d' ' -f2)
echo "Desktop is " $WIND
mkfifo /tmp/mplayer-control
touch /tmp/wallpaper-status
DesktopMovie -wid $WIND -x 1366 -y 768 -slave -input file=/tmp/mplayer-control -shuffle -loop 0 -playlist /home/axelectrik/.config/wallpaper/playlist.m3u &> /tmp/wallpaper-status &
echo "Playing" $WIND

ANd the output of /tmp/wallpaper-status is:

Cannot find HOME directory.
The wid option must be an integer: -x
Error parsing commandline option "-wid": Option parameter could not be parsed
MPlayer2 2.0-726-g6c87a98 (C) 2000-2012 MPlayer Team

So I don't know why the service cannot start xfdesktop, or if is already started why xwininfo is not giving the xfdesktop window ID so mplayer starts over there.

Last edited by axelectrik (2013-11-02 18:23:21)

Offline

Board footer

Powered by FluxBB