maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   MeeGo / Harmattan (https://talk.maemo.org/forumdisplay.php?f=45)
-   -   [SCRIPT] Restart wazapp automatically upon crash! (https://talk.maemo.org/showthread.php?t=85258)

godofwar424 2012-07-04 17:12

[SCRIPT] Restart wazapp automatically upon crash!
 
Hi,

I suffer from alot of random Wazapp crashes due to either signal loss or just PSM interfering.

For the moment I came up with a solution to missing messages due to a crash.

I want to make a script and then have it run every 30 mins or so to check if Wazapp is running and if it isn't restart it.

Here is what I have so far but there are errors I can't seem to solve, hoping you guys can help correct this :)

EDIT: This is the latest version that works!

Code:

#!/bin/sh

#set -x

#
# Variables Section
#==============================================================
# list process to monitor in the variable below.
#{wazapp} /usr/bin/python /opt/waxmppplugin/bin/wazapp/

PROGRAM1="wazapp"


# varible checks to see if $PROGRAM1
# is running.

APPCHK=$(ps aux | grep -C $PROGRAM1)

#
#
#==================================================================

# The ‘if’ statement below checks to see if the process is running
# with the ‘ps’ command.  If the value is returned as a ’0' then
# an email will be sent and the process will be safely restarted.
#


if [ $APPCHK = '0' ];

then

/opt/waxmppplugin/bin/wazapp/wazapp

else

echo 'Wazapp is running'

fi

echo $APPCHK

exit

PS. This idea was taken from this guys idea of a script for a similar purpose.

http://www.savelono.com/linux/bash-a...s-running.html

godofwar424 2012-07-04 19:55

Re: [SCRIPT HELP] Process is running or not
 
Newer Version of the script

Code:

#!/bin/sh

#set -x

#
# Variables Section
#==============================================================
# list process to monitor in the variable below.
#{wazapp} /usr/bin/python /opt/waxmppplugin/bin/wazapp/

PROGRAM1="wazapp"

#lists pid of that process

PID1=$(pidof $PROGRAM1)

#
#
#==================================================================

# The ‘if’ statement below checks to see if the process is running
# with the ‘ps’ command.  If the value is returned as a ’0' then
# an email will be sent and the process will be safely restarted.
#


if [ $PID1 = '' ];

then

/opt/waxmppplugin/bin/wazapp/wazapp

else

echo 'Wazapp is running'

fi

exit


godofwar424 2012-07-04 21:13

Re: [SCRIPT HELP] Process is running or not
 
SOLVED! :D

Big Thanks to ZogG and Doc_Scrutinizer

Vromoth 2012-07-04 21:21

Re: [SCRIPT HELP] Process is running or not
 
Edit the title name to "[SOLVED][SCRIPT HELP] Process is running or not" or whatever. :)

godofwar424 2012-07-04 22:38

Re: [SCRIPT] Process is running or not
 
End result script works great here are the two scripts created from this idea! :)

INSTRUCTIONS!

Connect your N9 to your computer via USB and copy the waxmppplugin.desktop and wazapp.sh file onto your Device.

Now unplug the USB and open the Terminal, and type in the following. If any commands give a permissions error, try again as root.

Code:

cp /home/user/MyDocs/wazapp.sh /home/user/
cp /home/user/MyDocs/waxmppplugin.desktop /usr/share/applications/
chmod 755 /home/user/wazapp.sh
chmod 644 /usr/share/applications/waxmppplugin.desktop

Custom Wazapp.desktop

Wazapp.sh

Original Wazapp.desktop


If script 2 is place in /home/user/ and saved as wazapp.sh then using this .desktop file to replace the default one for Wazapp, you can achieve a Wazapp that will restart itself if it errors for any reason :)

If you Quit the app yourself, it will not restart until you do it manually :)

Scipt 1 (ZogG)

Script 2 (Doc_Scrutinizer)

ZogG 2012-07-05 15:35

Re: [SCRIPT] Process is running or not
 
Quote:

Originally Posted by godofwar424 (Post 1232066)
End result script works great here are the two scripts created from this idea! :)

Scipt 1 (VogG)

Script 2 (Doc_Scrutinizer)

If script 2 is place in /home/user/ and saved as wazapp.sh then using this .desktop file to replace the default one for Wazapp, you can achieve a Wazapp that will restart itself if it errors for any reason :)

If you Quit the app yourself, it will not restart until you do it manually :)

Custom Wazapp.desktop

fix my nick name please =)

eltoffer 2012-07-05 19:03

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
ok i used only script 2 and the new desktop file but wazapp wont load, any clue?

godofwar424 2012-07-05 19:36

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by eltoffer (Post 1232539)
ok i used only script 2 and the new desktop file but wazapp wont load, any clue?

Did you put the script in /hom/user/ and name it wazapp.sh

and put the .desktop file in /usr/share/applications/

godofwar424 2012-07-05 19:37

Re: [SCRIPT] Process is running or not
 
Quote:

Originally Posted by ZogG (Post 1232461)
fix my nick name please =)

Sorry mate :p

Fixed now

eltoffer 2012-07-05 20:06

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by godofwar424 (Post 1232558)
Did you put the script in /hom/user/ and name it wazapp.sh

and put the .desktop file in /usr/share/applications/

yup yup but no load :(

ZogG 2012-07-05 20:14

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by eltoffer (Post 1232574)
yup yup but no load :(

did you gave the rights for script to have permission for execution?

chmod +x foo-bar.sh

herno24 2012-07-05 20:57

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by ZogG (Post 1232579)
did you gave the writes for script to have permission for execution?

chmod +x foo-bar.sh

Same here, how do i give that permission?

ZogG 2012-07-05 21:06

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by herno24 (Post 1232592)
Same here, how do i give that permission?

i think i posted command in above reply...

herno24 2012-07-05 21:09

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by ZogG (Post 1232596)
i think i posted command in above reply...

Ok, i'm not an expert, but i want to learn, so, how do i use that command?.

godofwar424 2012-07-05 21:35

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by eltoffer (Post 1232574)
yup yup but no load :(

Crap my bad, I forgot a major thing!

do the following command in terminal :)

Code:

chmod +x /home/user/wazapp.sh
You may have to do this as root.

Fixed this in the original post

ZogG beat me to it :p

herno24 2012-07-05 21:55

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Code:

devel-su
pass: rootme
chmod +x /home/user/wazapp.sh

it says "Operation not permitted"

godofwar424 2012-07-05 21:56

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by herno24 (Post 1232624)
Code:

devel-su
pass: rootme
chmod +x /home/user/wazapp.sh

it says "Operation not permitted"

Have you tried without being root?

ZogG 2012-07-05 22:10

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by herno24 (Post 1232624)
Code:

devel-su
pass: rootme
chmod +x /home/user/wazapp.sh

it says "Operation not permitted"

are you sure you are root?

than what does this command shows?

lsof |grep 'wazapp.sh'

omar451451 2012-07-05 22:34

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
I hope you've suggested this for wazapp's upcoming version !!! Don't wanna mess up with terminal so just hope to see this addition with the public release of the next version !!!

herno24 2012-07-05 22:35

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by ZogG (Post 1232630)
are you sure you are root?

than what does this command shows?

lsof |grep 'wazapp.sh'

it i'snt showing anything.

ZogG 2012-07-05 22:55

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by herno24 (Post 1232639)
it i'snt showing anything.

than you trying to do it not as root i think. how did you copy file there at first place?

herno24 2012-07-05 23:41

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by ZogG (Post 1232643)
than you trying to do it not as root i think. how did you copy file there at first place?

Using filebox (normal filebox, i couldn't with fileboxRoot).

godofwar424 2012-07-06 01:05

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by herno24 (Post 1232639)
it i'snt showing anything.

Please check the /home/user/ directory to make sure that wazapp.sh is actually in there?

Also are you able to start wazapp by typing this as a NON ROOT user into terminal

Code:

/opt/waxmppplugin/bin/wazapp/wazapp

herno24 2012-07-06 02:08

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
yes, the file is in there and i can open wazzap using terminal.

godofwar424 2012-07-06 02:22

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by herno24 (Post 1232693)
yes, the file is in there and i can open wazzap using terminal.

Try this via terminal and tell me the outome, quit wazapp first.


Code:

cd /home/user/
sh wazapp.sh

This should start wazapp via terminal the same as if you typed in the previous command i gave you.

Let me know the outcome.

eltoffer 2012-07-06 02:26

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by ZogG (Post 1232579)
did you gave the writes for script to have permission for execution?

chmod +x foo-bar.sh

hehehe i think it was all about permissions let me try, but i guess it should works

eltoffer 2012-07-06 02:40

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by ZogG (Post 1232579)
did you gave the writes for script to have permission for execution?

chmod +x foo-bar.sh

noup it neither worked for me :/ any idea?

eltoffer 2012-07-06 03:00

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
please check you desktop file i think this is the problem :/

godofwar424 2012-07-06 10:02

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by eltoffer (Post 1232714)
please check you desktop file i think this is the problem :/

Can you run the script manually?

By opening terminal and typing

Code:

cd /home/user/
sh wazapp.sh


bnwg 2012-07-06 10:32

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Yes, it can start by running the script in terminal but not by tapping the custom desktop file

godofwar424 2012-07-06 10:42

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by bnwg (Post 1232833)
Yes, it can start by running the script in terminal but not by tapping the custom desktop file

Please type this into Terminal and tell me the results:

Code:

devel-su
rootme
cd /usr/share/applications/
chmod 644 waxmppplugin.desktop
cd /home/user/
chmod 755 wazapp.sh

Then open up Wazapp icon on the desktop and tell me what happens, you have to wait a little while for it to start 5-15 seconds

If you recieve permission errors then try the commands that errored as a normal NON ROOT user.

ZogG 2012-07-06 10:46

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by eltoffer (Post 1232707)
noup it neither worked for me :/ any idea?

Let's be clear on that I do not know anything about desktop file. All i assume is you have some script, so all you need to run it is:
chmod +x "/path/to/script.sh" && /path/to/./script.sh

godofwar424 2012-07-06 10:52

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
I have updated the instructions in the initial post, please follow the new instructions:

http://talk.maemo.org/showpost.php?p...66&postcount=5

bnwg 2012-07-06 12:05

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by godofwar424 (Post 1232845)
I have updated the instructions in the initial post, please follow the new instructions:

http://talk.maemo.org/showpost.php?p...66&postcount=5

Thxk. It works now.

The code can be input as non-root except the last line

GBlaster 2012-07-08 19:47

Re: [SCRIPT] Process is running or not
 
Quote:

Originally Posted by godofwar424 (Post 1232066)
End result script works great here are the two scripts created from this idea! :)

INSTRUCTIONS!

Connect your N9 to your computer via USB and copy the waxmppplugin.desktop and wazapp.sh file onto your Device.

Now unplug the USB and open the Terminal, and type in the following. If any commands give a permissions error, try again as root.

Getting a "can't create" with the first command line. Running as root

Have to try as non-root, if it works keep going till you find a problem. After that try as root.

GBlaster 2012-07-08 20:13

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
I wonder if it is possible to run the script using the default .desktop file?

godofwar424 2012-07-08 23:13

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by GBlaster (Post 1234026)
Getting a "can't create" with the first command line. Running as root

Have to try as non-root, if it works keep going till you find a problem. After that try as root.

In order to move a file to the /home/user/ you need to be NON-root, and to move it to the /usr/share/applications/ you need to be Root!

Hope that helps :)

Quote:

Originally Posted by GBlaster (Post 1234037)
I wonder if it is possible to run the script using the default .desktop file?

That is the default .desktop file mate, I just edited it so that it opens the script and NOT wazapp directly :)

Thats why it has the same name and icon and everything else :)

GBlaster 2012-07-09 01:25

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by godofwar424 (Post 1234105)
In order to move a file to the /home/user/ you need to be NON-root, and to move it to the /usr/share/applications/ you need to be Root!

Hope that helps :)



That is the default .desktop file mate, I just edited it so that it opens the script and NOT wazapp directly :)

Thats why it has the same name and icon and everything else :)

Got it! Maybe you've already explained but I'm too lazy xD. Is it normal for the app to stop showing the splash screen when launched? Thanx!

godofwar424 2012-07-09 10:46

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
Quote:

Originally Posted by GBlaster (Post 1234148)
Got it! Maybe you've already explained but I'm too lazy xD. Is it normal for the app to stop showing the splash screen when launched? Thanx!

Yes, this launches wazapp directly without the splashscreen.

Tbh the splashscreen stays on for too long sometimes and its not really a useful feature to me :P

chasetheangel 2012-07-09 11:27

Re: [SCRIPT] Restart wazapp automatically upon crash!
 
@GOW424

Just a feedback:

I think most of the crashes on Wazapp that Im using is/was caused by switching of connections from Wifi to 3g and vice versa. Some of this crashes, the UI just hanged without any activity. I tried the script and experienced while it tried to reconnect the hanged Wazapp, it comes to a loop of 'connecting', 'online', 'offline'. Is there anyway to make the script to completely shutdown the app before restart and connect?

BTW, I'm using the dev version. I've able to avoid the hanged Wazapp crash by staying on 3g all the time and completely disabling Wifi connection for it.


All times are GMT. The time now is 23:34.

vBulletin® Version 3.8.8