Author Topic: Best to shutdown all AppleScripts before shutting down WeatherCat  (Read 3230 times)

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6494
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
Dear WeatherCat AppleScript fans,

Those who have been "dabbling in AppleScripts" since their humble beginnings with LWC may recall that all of the ones that run continuously check to see if WeatherCat (then LWC) is running before making a request.  This in principle should allow you to quit WeatherCat without having the scripts disturbed and restart WeatherCat with all the AppleScripts still patiently waiting to go back to work.

Unfortunately, times have changed.  The number of scripts potentially requesting data has increased.  With each one, there is an increasing chance it will make a request while WeatherCat is shutting down.  The trouble is that an AppleScript cannot know if an application is in the process of shutting down; only if there is no such process running.  If an AppleScript makes a request while WeatherCat is still running, but has shutdown the AppleScript interface,  the Finder will wait the specified interval and try the request again.  That will cause WeatherCat to be launched unexpectedly

Further complicating things is that if you use my Start WeatherCat Scripts launcher.  It deliberately puts gaps of 10 to 15 seconds to reduce the load on WC AppleScript Tags Processor.  Since several of the scripts collect data once a minute . . . it is going to be much harder to try to "stealthfully" quit WeatherCat without some AppleScript inadvertently restarting it.

Now that I've added the  Start WeatherCat Scripts and Stop WeatherCat Scripts which work well as far as I can tell, I recommend taking the opposite strategy.  If you need to quit WeatherCat, bite the bullet and shut down all the AppleScripts before hand.  It is easy enough to do.  When you start up WeatherCat, reverse the procedure and start up all the AppleScripts.  It is a bit slower, but it is much more positive and trouble-free.

Cheers, Edouard  [cheers1]

Tornado Tim

  • Strong Breeze
  • ***
  • Posts: 125
    • Matangi Weather
  • Station Details: Davis VP2 with Solar and WLIP Datalogger (via VVP)
I made a scrip that will close all applescript apps, on WC shutdown, just set that in Weather Cats advanced preferences. That way do dont need to close stuff by yourself.

elagache

  • Global Moderator
  • Storm
  • *****
  • Posts: 6494
    • DW3835
    • KCAORIND10
    • Canebas Weather
  • Station Details: Davis Vantage Pro-2, Mac mini (2018), macOS 10.14.3, WeatherCat 3
Shutdown script now included (Re: shutdown all AppleScripts)
« Reply #2 on: May 10, 2012, 10:16:32 PM »
Hi Tim and WeatherCat AppleScript fans,

I made a scrip that will close all applescript apps, on WC shutdown

Startup and shutdown scripts are now included in the latest distribution so everyone can have this without needing to learn AppleScript.  By the way, you might want to switch to the new scripts I've included if you are using more than 1 or 2 of the AppleScripts.  The order with which scripts are started and stopped matters.  Also, it is best to insert some delays between launching the AppleScripts if you are using WC AppleScript Tags Processor to avoid causing that script to use excessive CPU.

Cheers, Edouard  [cheers1]