[SOLVED]sql-logger finished at start up flag

Posted on
Thu May 08, 2014 1:09 pm
kw123 offline
User avatar
Posts: 5822
Joined: May 12, 2013
Location: Dallas, TX

[SOLVED]sql-logger finished at start up flag

is there a flag to indicate that SQL Logger is finished when indigo is starting?

I have some sql reads running and at startup they sometimes come back with no data. It depends on the sequence when they are starting.
Somewhere in the middle of all the startup activities the message log it shows:


SQL Logger connected to /Library/Application Support/Perceptive Automation/Indigo 6/Logs/indigo_history.sqlite
SQL Logger searching for unused device and variable tables
SQL Logger search complete (none found)
SQL Logger updating all device tables
SQL Logger updating all variable tables
SQL Logger update complete


I would like to delay the sql activity until SQL Logger is done.

thanks

Karl
Last edited by kw123 on Fri May 09, 2014 12:43 pm, edited 1 time in total.

Posted on
Fri May 09, 2014 9:36 am
jay (support) offline
Site Admin
User avatar
Posts: 14648
Joined: Mar 19, 2008
Location: Austin, Texas

Re: sql-logger finished at start up flag

Nope. You can't really depend on that anyway because you don't know when the user is going to start/stop the logger anyway so you just need to detect any odd situations and recover appropriately.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri May 09, 2014 9:45 am
kw123 offline
User avatar
Posts: 5822
Joined: May 12, 2013
Location: Dallas, TX

Re: sql-logger finished at start up flag

ok thx,

tried:
Code: Select all
indigo.server.getPlugin("com.perceptiveautomation.indigoplugin.sql-logger").isEnabled()


that gives "True" in the middle of the SQL-logger startup.

Is there a way to check the log file for "SQL Logger update complete"

or better is there up-time info for indigo, i.e. check if uptime > 1 minute

Karl

Posted on
Fri May 09, 2014 12:24 pm
kw123 offline
User avatar
Posts: 5822
Joined: May 12, 2013
Location: Dallas, TX

Re: sql-logger finished at start up flag

This seems to work:

Code: Select all
   def procUPtime(self,process):
      CPUtime = subprocess.Popen("ps -ef | grep "+process+" | grep -v grep | awk '{print $7}'" ,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()[0]
      if len(CPUtime) < 4 or len(CPUtime) > 12: return -1 # not found (string either too short =junk, to too long must be error message)
      else:
         temp=CPUtime.strip("\n").split(":")
         try:
            if len(temp) ==3: CPUtime = float(temp[0])*60*60 + float(temp[1])*60 +float(temp[2]) # hours:minutes:seconds.milsecs
            if len(temp) ==2: CPUtime =                        float(temp[0])*60 +float(temp[1]) # minutes:seconds.milsecs
            if len(temp) ==1: CPUtime =                                           float(temp[0]) # seconds.milsecs
         except:
            CPUtime =0.
         if CPUtime  >5.: up = 10   # proc is up long enough
         if CPUtime <=5.: up = 5      # proc is still starting up, delay other sql activity 10 seconds
         if CPUtime ==0.: up = 0      # proc is not running
      return up


the attached code returns:

-1 if process not found
0 if no cpu time used by process
5 if less than 5 secs cpu time used by process
10 if > 5 sec cpu time used by process

call:
if self.procUPtime("Logger.indigoPlugin") < 10: self.sleep(15) # wait 15 seconds for sql logger to finish startup.


Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest