Maintenance Script to ensure other applications are running.

Ask questions about integrating other services (internet and otherwise) and applications with Indigo.
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Maintenance Script to ensure other applications are running.

Post by whmoorejr »

Forgive me if this is already posted somewhere.... but I couldn't find it.

I'm looking to put a scheduled maintenance script that will run periodically to ensure that certain indigo supporting applications are running.... and if not, turn them back on.

Once in a blue moon Growl or Airfoil will "Quit Unexpectantly". Looking for a small script to check if X is running. True = end. False = start application X.

What's the best approach? Applescript or a Python script? (I've never done anything with Python).
Bill
My Plugin: My People
User avatar
marketability
Posts: 204
Joined: Tue Dec 08, 2015 11:41 am
Location: UK

Re: Maintenance Script to ensure other applications are runn

Post by marketability »

There's a plugin I use that should help do that...

http://forums.indigodomo.com/viewtopic. ... 62&t=13678
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Maintenance Script to ensure other applications are runn

Post by whmoorejr »

marketability wrote:There's a plugin I use that should help do that...
Ooooh. I love getting new plugins. I just had a little indigogasm.
Bill
My Plugin: My People
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Maintenance Script to ensure other applications are runn

Post by whmoorejr »

Out of the 4 applications I want to keep running (Airfoil, Growl, Plex, Remotsighlt) That plugin is only showing the status of Remotsight. I'm going to keep looking for a script that can do this and keep tweeking with that plugin to see if I can accomplish my goals that way.

Interestingly, I can start any of those four applications with the plugin, but it's not giving me a status on 3 of the 4.
Bill
My Plugin: My People
User avatar
marketability
Posts: 204
Joined: Tue Dec 08, 2015 11:41 am
Location: UK

Re: Maintenance Script to ensure other applications are runn

Post by marketability »

Yes just noticed that AirFoul status no longer reports - It did work - maybe the recent airfoil update broke it
having said that the new airfoil pro plugin included in 7 has a status connected / unavailable?
bkmar1192
Posts: 274
Joined: Sat Sep 12, 2015 11:23 am

Re: Maintenance Script to ensure other applications are runn

Post by bkmar1192 »

I am currently on a bus and am doing this from memory but can give you specifics later today if you want. I do this through An external AppleScript. If my memory serves my correctly The script does a try open on the application. On success/failure I update a variable in Indigo.


Sent from my iPhone using Tapatalk
bkmar1192
Posts: 274
Joined: Sat Sep 12, 2015 11:23 am

Re: Maintenance Script to ensure other applications are runn

Post by bkmar1192 »

Here is the Apple Script snippet. I run this script every 15 minutes, if one of the application running variables becomes false then a trigger runs to try and restart the app.

-Bert

Code: Select all

set thedate to (characters 1 thru 3 of (weekday of (current date) as string) & ", " & characters 1 thru 4 of (month of (current date) as string) & " " & (day of (current date) as string) & "  " & time string of (current date)) as string

if application "iTunes" is running then
	set value of variable "iTunesRunning" to "true"
	set value of variable "iTunesLastRunning" to thedate
else
	set value of variable "iTunesRunning" to "false"
end if

if application "Airfoil" is running then
	set value of variable "AirfoilRunning" to "true"
	set value of variable "AirfoilLastRunning" to thedate
else
	set value of variable "AirfoilRunning" to "false"
end if

if application "IndigoServer" is running then
	set value of variable "IndigoServerRunning" to "true"
	set value of variable "IndigoServerLastRunning" to thedate
else
	set value of variable "IndigoServerRunning" to "false"
end if
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Maintenance Script to ensure other applications are runn

Post by whmoorejr »

bkmar1192 wrote:

Code: Select all

if application "IndigoServer" is running then
	set value of variable "IndigoServerRunning" to "true"
	set value of variable "IndigoServerLastRunning" to thedate
else
	set value of variable "IndigoServerRunning" to "false"
end if
I'm stealing your script! A couple questions though. How well does the script work if the indigo server is down? With only an instance of indigo client running, I wouldn't think you could adjust a variable from an outside script or fire off a trigger to restart the indigo server. (Maybe some additional scripting to re-start the server, delay for a bit then adjust a variable so you know that the indigo server had to be restarted.?).

I was having Issues with external apple scripts adjusting indigo variables when I was trying to tie sightHound software to indigo. (Sometimes it would work, sometimes it would get an 'AppleScript 600 error' .... something along those lines. Have you noted any similar errors or tried quitting applications to test the scripts?
Bill
My Plugin: My People
bkmar1192
Posts: 274
Joined: Sat Sep 12, 2015 11:23 am

Re: Maintenance Script to ensure other applications are runn

Post by bkmar1192 »

For issue #1 - that is why I put a date stamp in a variable. If the date hasn't updated in a while but it still shows active I know something more serious is going on.

I used to have some stability issues so I would restart everything periodically. But I stopped doing that because my system has stabilized.

On #2 - there is process in the mac that if you stop the process it usually fixes the app not found issue. I run a script every hour that kills the process - has pretty much eliminated that issue.

But just in case, I have another external script that updates a variable to true. I then have a scheduled event that a) sets the variable to false b) runs the script. If the variable stays false for too long I know that external scripts aren't working.

I'll post sample code a little later.


Sent from my iPhone using Tapatalk
User avatar
whmoorejr
Posts: 844
Joined: Tue Jan 15, 2013 11:23 am
Location: Houston, TX

Re: Maintenance Script to ensure other applications are runn

Post by whmoorejr »

bkmar1192 wrote:For issue #1 - ...
Thank You!

Sorry for the delay... Other indigo projects (and life) got in the way.

I've started running the script you posted every 15 minutes and works like a charm. Added a trigger for each "False" to re-start / activate a crashed app.
Bill
My Plugin: My People
Post Reply

Return to “Integrating Services/Applications”