Indigo-PhoneValet Integration

Posted on
Fri Nov 06, 2009 7:28 pm
BillC offline
Posts: 237
Joined: Mar 09, 2008

(No subject)

I have the same problem (snow leopard 10.6.1, Indigo 4.1.1, Phone Valet 6.0.3) with the variables occasionally not being updated. It's happening now, by chance, so I entered the ps command with the following results:

MacMini:~ homeauto$ ps -axwww | grep Indigo
137 ?? 50:47.29 /Library/Application Support/Perceptive Automation/Indigo 4/IndigoServer.app/Contents/MacOS/IndigoServer
180 ?? 47:20.48 /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python /Library/Application Support/Perceptive Automation/Indigo 4/IndigoWebServer/IndigoWebServer.py -i1176 -w8176 -cfn
41395 ?? 24:10.51 /Applications/Indigo 4.app/Contents/MacOS/Indigo 4 -psn_0_19341937
58144 ttys000 0:00.00 grep Indigo
MacMini:~ homeauto$

No background scripts...It's not just Phone Valet...restarted IndigoServer and now get:
MacMini:~ homeauto$ ps -axwww | grep Indigo
41395 ?? 24:12.25 /Applications/Indigo 4.app/Contents/MacOS/Indigo 4 -psn_0_19341937
58152 ?? 0:00.64 /Library/Application Support/Perceptive Automation/Indigo 4/IndigoServer.app/Contents/MacOS/IndigoServer
58153 ?? 0:01.07 /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python /Library/Application Support/Perceptive Automation/Indigo 4/IndigoWebServer/IndigoWebServer.py -i1176 -w8176 -cfn
58156 ?? 0:00.25 /usr/bin/osascript /Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/iTunes sync.scpt
58157 ?? 0:00.29 /usr/bin/osascript /Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/Weather NOAA sync.scpt
58158 ?? 0:00.19 /usr/bin/osascript /Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/PhoneValet Background Script.scpt
58165 ttys000 0:00.00 grep Indigo
MacMini:~ homeauto$

Posted on
Fri Nov 06, 2009 8:43 pm
jay (support) offline
Site Admin
User avatar
Posts: 18216
Joined: Mar 19, 2008
Location: Austin, Texas

(No subject)

BillC wrote:
I have the same problem (snow leopard 10.6.1, Indigo 4.1.1, Phone Valet 6.0.3) with the variables occasionally not being updated. It's happening now, by chance, so I entered the ps command with the following results:

MacMini:~ homeauto$ ps -axwww | grep Indigo
137 ?? 50:47.29 /Library/Application Support/Perceptive Automation/Indigo 4/IndigoServer.app/Contents/MacOS/IndigoServer
180 ?? 47:20.48 /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python /Library/Application Support/Perceptive Automation/Indigo 4/IndigoWebServer/IndigoWebServer.py -i1176 -w8176 -cfn
41395 ?? 24:10.51 /Applications/Indigo 4.app/Contents/MacOS/Indigo 4 -psn_0_19341937
58144 ttys000 0:00.00 grep Indigo
MacMini:~ homeauto$

No background scripts...It's not just Phone Valet...restarted IndigoServer and now get:
MacMini:~ homeauto$ ps -axwww | grep Indigo
41395 ?? 24:12.25 /Applications/Indigo 4.app/Contents/MacOS/Indigo 4 -psn_0_19341937
58152 ?? 0:00.64 /Library/Application Support/Perceptive Automation/Indigo 4/IndigoServer.app/Contents/MacOS/IndigoServer
58153 ?? 0:01.07 /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python /Library/Application Support/Perceptive Automation/Indigo 4/IndigoWebServer/IndigoWebServer.py -i1176 -w8176 -cfn
58156 ?? 0:00.25 /usr/bin/osascript /Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/iTunes sync.scpt
58157 ?? 0:00.29 /usr/bin/osascript /Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/Weather NOAA sync.scpt
58158 ?? 0:00.19 /usr/bin/osascript /Library/Application Support/Perceptive Automation/Indigo 4/Scripts/Background Tasks/PhoneValet Background Script.scpt
58165 ttys000 0:00.00 grep Indigo
MacMini:~ homeauto$


Yep, that's what I was afraid of. It kills some or all of my background scripts too, not just the PhoneValet script. I've been trying to track down anything that might be causing it and so far nothing. I have a time/date action that runs every minute and checks to see if the background tasks are running or not and it logs when they disappear so I can try to correlate with Console log entries, etc. So far nothing. I'll keep this thread posted on anything I can find.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Nov 06, 2009 8:56 pm
jay (support) offline
Site Admin
User avatar
Posts: 18216
Joined: Mar 19, 2008
Location: Austin, Texas

(No subject)

jay wrote:
Yep, that's what I was afraid of. It kills some or all of my background scripts too, not just the PhoneValet script. I've been trying to track down anything that might be causing it and so far nothing. I have a time/date action that runs every minute and checks to see if the background tasks are running or not and it logs when they disappear so I can try to correlate with Console log entries, etc. So far nothing. I'll keep this thread posted on anything I can find.


Has anyone else noticed that any of their stay-open background AppleScripts (iTunes Sync, NOAA Weather, etc) have just spontaneously stopped with no errors? I'd like to get a feel for how wide-spread the problem is. Thanks.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Nov 06, 2009 9:19 pm
JeffS offline
Posts: 34
Joined: Jul 14, 2008

(No subject)

Jay-

The results of the grep were:

518 ?? 3:27.61 /Library/Application Support/Perceptive Automation/Indigo 4/IndigoServer.app/Contents/MacOS/IndigoServer
529 ?? 8:55.98 /Applications/Indigo 4.app/Contents/MacOS/Indigo 4 -psn_0_307275
537 ?? 3:46.92 python /Library/Application Support/Perceptive Automation/Indigo 4/IndigoWebServer/IndigoWebServer.py -i1176 -w8176 -cfn
538 ?? 2:00.90 python /Library/Application Support/Perceptive Automation/Indigo 4/IndigoSqlClient/IndigoSqlClient.py -i1176
29877 ttys000 0:00.00 grep Indigo


So I assume that it died...

Any suggestions?

Thanks for your quick attention and support!

Jeff

Posted on
Fri Nov 06, 2009 10:14 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

(No subject)

This is a work-around that might resolve the problem you are seeing with background scripts. Try launching the script from inside a simple watchdog shell shell, something like:
Code: Select all
#!/bin/sh

while [#!/bin/sh

while [ true ]
do
   /usr/bin/osascript ./test.scpt >> scripterr.log 2>&1
   DATE=`date`
   echo "test.scpt died at $DATE" >> scripterr.log
done

exit 0

To start the process, you'd just enter runscript.sh >> scripterr.log 2>&1 &

You could probably start all of your watchdog shells from an Indigo Startup trigger. Likewise, with a little tweaking, you could probably get the output from the shell into the Indigo log. See this web page.

Posted on
Fri Nov 06, 2009 10:53 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

(No subject)

I decided to try the logging to Indigo. It works. So, if you start your background AppleScript from an embedded Indigo AppleScript like
Code: Select all
do shell script "/Users/foo/bin/testscpt-watcher.sh &"
where testscpt-watcher.sh looks something like this:
Code: Select all
#!/bin/sh
while [ true ]
do
        /usr/bin/osascript ./test.scpt
        EXCODE=$?
        DATE=`date`
        /usr/bin/osascript ./indigoLogger.scpt test.scpt $EXCODE
done
exit 0
and this AppleScript (saved as indigoLogger.scpt)
Code: Select all
on run argv
   tell application "IndigoServer"
      log "Script " & item 1 of argv & " died with exit code " & item 2 of argv & " and was restarted" using type "Background Script"
   end tell
end run
you get Indigo log messages like
Code: Select all
Nov 6, 2009 8:38:45 PM
  Background Script  Script test.scpt died with exit code 143 and was restarted
anytime the background script dies and needs to be restarted.

You could generalize this script to pass the background script name on the command line and then call it like:do shell script "/Users/foo/bin/watchdog.sh test.scpt" That way you'd only need one shell script to start and monitor any background task.

If there is sufficient interest, I can clean all this up and post it to the user contributions library with some basic documentation.

Posted on
Sat Nov 07, 2009 5:06 am
BillC offline
Posts: 237
Joined: Mar 09, 2008

(No subject)

@berkinet, I'm going to be busy this weekend but when I get a few minutes free I'll see if I can get your script running...thanks!

Jay, you might post that question (other users w/ problem) as its own topic in the applescript section, don't know how much traffic this thread gets and the problem is not limited to PV.

NOTE: I made an error in my post above, my homeauto computer is NOT running Snow Leopard, it's on 10.5.8 (it's the only one I haven't upgraded yet). Other program versions are correct.

Posted on
Sat Nov 07, 2009 8:25 am
jay (support) offline
Site Admin
User avatar
Posts: 18216
Joined: Mar 19, 2008
Location: Austin, Texas

(No subject)

BillC wrote:
NOTE: I made an error in my post above, my homeauto computer is NOT running Snow Leopard, it's on 10.5.8 (it's the only one I haven't upgraded yet). Other program versions are correct.


Good information, thanks, now I have 2 cases where it's happening on Leopard.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Nov 07, 2009 8:26 am
jay (support) offline
Site Admin
User avatar
Posts: 18216
Joined: Mar 19, 2008
Location: Austin, Texas

(No subject)

berkinet wrote:
I decided to try the logging to Indigo. It works. So, if you start your background AppleScript from an embedded Indigo AppleScript like
Code: Select all
do shell script "/Users/foo/bin/testscpt-watcher.sh &"
where testscpt-watcher.sh looks something like this:
Code: Select all
#!/bin/sh
while [ true ]
do
        /usr/bin/osascript ./test.scpt
        EXCODE=$?
        DATE=`date`
        /usr/bin/osascript ./indigoLogger.scpt test.scpt $EXCODE
done
exit 0
and this AppleScript (saved as indigoLogger.scpt)
Code: Select all
on run argv
   tell application "IndigoServer"
      log "Script " & item 1 of argv & " died with exit code " & item 2 of argv & " and was restarted" using type "Background Script"
   end tell
end run
you get Indigo log messages like
Code: Select all
Nov 6, 2009 8:38:45 PM
  Background Script  Script test.scpt died with exit code 143 and was restarted
anytime the background script dies and needs to be restarted.

You could generalize this script to pass the background script name on the command line and then call it like:do shell script "/Users/foo/bin/watchdog.sh test.scpt" That way you'd only need one shell script to start and monitor any background task.

If there is sufficient interest, I can clean all this up and post it to the user contributions library with some basic documentation.


Great idea Richard, my logger is only logging when it dies - maybe the exit code will tell us something more.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Nov 08, 2009 11:13 am
BillC offline
Posts: 237
Joined: Mar 09, 2008

(No subject)

I'm trying to run berkinet's scripts and the PV background script isn't starting.

I'm using
Code: Select all
do shell script "/Library/Application Support/Perceptive Automation/Test/testscpt-watcher.sh &"
in a startup trigger action.

My testscpt-watcher.sh:
Code: Select all
#!/bin/sh
while [ true ]
do
   /usr/bin/osascript "/Library/Application Support/Perceptive Automation/Test/PhoneValet Background Script.scpt"
   EXCODE=$?
   DATE='date'
   /usr/bin/osascript "/Library/Application Support/Perceptive Automation/Test/indigoLogger.scpt PhoneValet Background Script.scpt $EXCODE"
done
exit 0

My indigoLogger.scpt:
Code: Select all
on run argv
   tell application "IndigoServer"
      log "Script " & item 1 of argv & " died with exit code " & item 2 of argv & " and was restarted" using type "Background Script"
   end tell
end run

No errors in Indigo or console logs, but the PV script never starts (at least doesn't show up in ps immediately after starting the server).

Edit to add: Contents of /Library/Application Support/Perceptive Automation/Test/
Code: Select all
MacMini:Test homeauto$ ls -al
total 80
drwxr-xr-x  5 xxxxxx  admin    170 Nov  8 11:02 .
drwxrwxr-x  5 root     admin    170 Nov  8 10:51 ..
-rw-rw-rw-@ 1 xxxxxx  admin  18272 Oct 17 12:07 PhoneValet Background Script.scpt
-rw-rw-rw-@ 1 xxxxxx  staff   1552 Nov  8 11:02 indigoLogger.scpt
-rwxrwxrwx@ 1 xxxxxx  admin    313 Nov  8 11:59 testscpt-watcher.sh
MacMini:Test homeauto$

Posted on
Sun Nov 08, 2009 12:56 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

(No subject)

is testscpt-watcher.sh executable? (chmod 755 testscpt-watcher.sh)

Posted on
Sun Nov 08, 2009 2:01 pm
BillC offline
Posts: 237
Joined: Mar 09, 2008

(No subject)

berkinet wrote:
is testscpt-watcher.sh executable? (chmod 755 testscpt-watcher.sh)


I think so...

-rwxrwxrwx@ 1 xxxxxx admin 313 Nov 8 11:59 testscpt-watcher.sh

Posted on
Sun Nov 08, 2009 2:09 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

(No subject)

Hmmm. What do you get if you just run testscpt-watcher.sh from a terminal window. Try something like:

./testscpt-watcher.sh >> log.txt 2>&1 &

Then run the ps command to see if your script started. If it works from the terminal window, then you might try your embedded AS command in AppleScript Editor inside of a tell block and watch the Events/replies.

EDIT: If it doesn't work from the command line, see what log.txt has recorded.

Posted on
Sun Nov 08, 2009 2:25 pm
BillC offline
Posts: 237
Joined: Mar 09, 2008

(No subject)

Hmmm. What do you get if you just run testscpt-watcher.sh from a terminal window. Try something like:
./testscpt-watcher.sh >> log.txt 2>&1 &

That started the script. log.txt is empty.

try your embedded AS command in AppleScript Editor inside of a tell block and watch the Events/replies.

Like this?
Code: Select all
tell application "Finder"
   do shell script "/Library/Application Support/Perceptive Automation/Test/testscpt-watcher.sh &"
end tell


Result is a null string (two double quotation marks with nothing between).

Thanks for the help...I'm barely literate in AS and probably not even that in shell scripts.

Posted on
Sun Nov 08, 2009 2:33 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

(No subject)

BillC wrote:
...Thanks for the help...I'm barely literate in AS and probably not even that in shell scripts.
Don't sell yourself short. You seem to be doing fine.

I was thinking you would use:
tell application "IndigoServer"

But, in fact, just get rid of the tell and end tell lines and try it with just the do shell script command.

Who is online

Users browsing this forum: No registered users and 3 guests