You are not logged in.

#1 2015-01-19 22:57:47

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

Keep persistent applications

Well basically what I need is some way for certain applications to be always running and that in case they're killed or crashed they re-open automatically.
Let's say what I need to be persistent would be:
- Cairo-Dock
- Avant Dock
- Mplayer ( I use it to keep my wallpaper with movies)
- Banshee and osd-lyrics
I'm assuming maybe they could be like in a service, so any idea would be appreciated.
Thank you

Offline

#2 2015-01-19 23:07:03

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

Re: Keep persistent applications

Start them in a while loop.


Moving to NC...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2015-01-20 00:03:06

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Keep persistent applications

How many instances of these applications do you want running at one time? What exactly do you do with mplayer?

Offline

#4 2015-01-20 00:11:24

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,559
Website

Re: Keep persistent applications

Are any of those crashing?  If so, why not figure out the root of the problem rather than just trying to ignore it?


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2015-01-20 01:22:37

mwillems
Member
Registered: 2014-08-09
Posts: 89

Re: Keep persistent applications

Cron jobs: run a script at intervals (once a minute, etc.) to 1) test if the programs are running, and, 2) log a crash and relaunch them if necessary. 

But anything like that is just an insurance policy/bandaid; if you're getting crashes, Trilby's solution is the right one.

Last edited by mwillems (2015-01-20 01:24:50)

Offline

#6 2015-01-26 05:32:30

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

Re: Keep persistent applications

Thank you all for your suggestions, sorry I haven't been able to post.
I know I should find the root cause of crashes but these are extremely random:

 - Cairo-Dock // Nothing unusual but suddenly it just won't appear when I go to theedge of the screen (where it's hidden) and of course the command isn't running anymore
 - Mplayer // I keep it running my anime as wallpaper BUT sometimes it just gets frozen, the command still running (in zombie mode), 
                     if running in console the output is just the frozen duration/progress of the movie and it will remain like that until I kill the process (sigterm also won't stop it)
 - Banshee // This one is the weirdest of all but I'll have to log all the output and post it later. Randomly the process shown as "Main" in Task Manager starts using incredible amount of CPU, leading to a system freeze unless I kill the process first. 
                      Until now I haven't been able to find a pattern, this happens either playing or in standby.
 - Osdlyrics // Of these one I have the reason of the crash but not on my hands to be resolved. It crashes when any lyrics contains special characters (such as assian or cyrilic letters)

About the suggested options
- A while loop kills my system, I have tried already but since the behaviour of these commands are unpredictible it leads to freeze the system (such as mplayer "playing" null or osdlyrics being restarted repeatedly while playing kpop or russian songs XD )
- CRON JOBS!! Haven't heard of cron for a while, thought it was deprecated, anyway sounds great to try, just any help on the script please? smile Just on how to get the logs for everything.

Again, thank you everyone you've been extremely helpul big_smile

Offline

#7 2015-01-26 10:38:11

Awebb
Member
Registered: 2010-05-06
Posts: 6,309

Re: Keep persistent applications

Osdlyrics is probably missing fonts or locale settings.

The rest sounds like something is broken. If it was just Cairo-Dock and Banshee, I'd say the software is broken, but since mplayer acts up as well, I'd put my money on a hardware issue.

Offline

#8 2015-01-26 13:11:03

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,559
Website

Re: Keep persistent applications

axelectrik wrote:

- A while loop kills my system, I have tried already but since the behaviour of these commands are unpredictible it leads to freeze the system (such as mplayer "playing" null or osdlyrics being restarted repeatedly while playing kpop or russian songs XD )

Then you've written the loop incorrectly.  If you post it here, we could help.  Mplayer will not randomly chose to play "null" - I don't even know what that means.  If you write bad code, however, it could very easily not do what you intended.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2015-01-26 21:46:21

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

Re: Keep persistent applications

Ok this is the scrip I tried to use for osdlyrics:

while :; 
do osdlyrics  &> /dev/null ; 
done

It will repeat indefineatly unless it's running, problem is that if I'm playing sungs such as "Нас не догонят" and all the lyrics are in these characters it wont stop crashing-reopening untils the song is over (most of the times songs won't get to finish because the infinite loop causes everything  to crash or system freeze).
BOut the libraries and locale settings, yes I will try that! Weird thing isthat it actually displays the "special characters" for a second and then it breaks, still I 'll give it a try wink

For mplayer playing "null" the output is this

mplayer /files/Video/Anime/Afro\ Samurai/Afro\ Samurai\ -\ 1x03.mp4 
MPlayer2 UNKNOWN (C) 2000-2012 MPlayer Team
Cannot open file '/home/axelectrik/.mplayer/input.conf': No such file or directory
Failed to open /home/axelectrik/.mplayer/input.conf.

Playing /files/Video/Anime/Afro Samurai/Afro Samurai - 1x03.mp4.
Detected file format: QuickTime / MOV (libavformat)
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (aac), -aid 0, -alang und
Clip info:
 major_brand: isom
 minor_version: 1
 compatible_brands: isomavc1
 creation_time: 2008-10-06 22:34:16
 title: Afro Samurai - 03
 compilation: 0
Load subtitles in /files/Video/Anime/Afro Samurai/
Forced video codec: ffmpeg12vdpau
Forced video codec: ffwmv3vdpau
Forced video codec: ffvc1vdpau
Forced video codec: ffh264vdpau
Selected video codec: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration) [libavcodec]
Selected audio codec: AAC (Advanced Audio Coding) [libavcodec]
AUDIO: 44100 Hz, 2 ch, floatle, 32.0 kbit/1.13% (ratio: 4000->352800)
AO: [pulse] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...
VIDEO:  704x396  24.000 fps  268.1 kbps (33.5 kB/s)
VO: [vdpau] 704x396 => 704x396 H.264 VDPAU acceleration 
[vdpau] Compositing window manager detected. Assuming timing info is inaccurate.
VIDEO:  704x396  24.000 fps  268.1 kbps (33.5 kB/s)
VO: [vdpau] 704x396 => 704x396 H.264 VDPAU acceleration 
[vdpau] Compositing window manager detected. Assuming timing info is inaccurate.
A:   1.1 V:   1.2 A-V: -0.000 ct: -0.000   0/  0 24%  0%  1.3% 0 0 

It will just remain with the same info in the tail of the output until I manually "hard" kill it, as for the movie just stays stuck in the same frame.

My code for the wallpaper is (wall-player is a symlink to /usr/bin/mplayer):

#!/bin/bash

mkfifo /tmp/mplayer-control
touch /tmp/mplayer.stat

DOPLAYLIST=$(ls /files/Video/Wallpaper/*mp4 > /xtra/wallpaper/playlistN.m3u) 
WALLIE="wall-player -wid $(xdotool search --name 'Escritorio') -slave -input file=/tmp/mplayer-control -fs -aspect 16:9 -shuffle -saturation 60 -contrast -3 /xtra/wallpaper/videos/* &> /tmp/mplayer.stat"

mv /xtra/wallpaper/playlistN.m3u /xtra/wallpaper/playlistBACKUP.m3u
$DOPLAYLIST

sleep 5

while :;
do  if pgrep wall-player > /dev/null 2>&1 
    then
      echo "Found"  
      echo "Found // Do nothing" &> /tmp/wallpaper.stat    
    else
      echo "Not Found"
      echo "Not Found // Starting Wallpaper" &> /tmp/wallpaper.stat
      $WALLIE &>/dev/null 2>&1 &&
      wallpaper      
    fi
done 

My intention in the end is for "wallpaper" command to be restarted if wall-player crashes or gets killed, the problem is that it won't get killed by itself.

Again, thank you big_smile

Last edited by axelectrik (2015-01-26 21:46:50)

Offline

Board footer

Powered by FluxBB