[ANSWERED]how to stop and restart indigo

Posted on
Mon Dec 16, 2013 3:53 pm
kw123 offline
User avatar
Posts: 8374
Joined: May 12, 2013
Location: Dallas, TX

[ANSWERED]how to stop and restart indigo

I have been trying to stop indigo and restart it, but no matter what i do it always comes back

1) in indigo do a server stop, stops it for a moment and server and all plugins relaunch after ~ 5 seconds, but indigo stays in disconnect mode, have to relaunch server

unix Kill :
sudo -S kill -9 `ps aux | grep 'Indigo' |grep -v 'grep' | awk '{print $2}'`
kills all Indigo PIDS , but it comes back after ~ 5 seconds

Any idea what I am doing wrong?

this is to do a double start / relaunch after login or reboot such that the applescripts continue to run.

thanks

Karl

Posted on
Mon Dec 16, 2013 4:06 pm
jay (support) offline
Site Admin
User avatar
Posts: 18246
Joined: Mar 19, 2008
Location: Austin, Texas

Re: how to stop and restart indigo

A reboot doesn't change anything?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 16, 2013 4:22 pm
kw123 offline
User avatar
Posts: 8374
Joined: May 12, 2013
Location: Dallas, TX

Re: how to stop and restart indigo

no, this is after reboot, have done it 5 times. is there anything that automatically relaunches indigo?

Posted on
Mon Dec 16, 2013 5:34 pm
kw123 offline
User avatar
Posts: 8374
Joined: May 12, 2013
Location: Dallas, TX

Re: how to stop and restart indigo

this is roughly (brut force) what i would like to do to fix the "application not running" message:

Karl

Code: Select all
-- kill indigo and restart it
set theAPP to "/Applications/Indigo 6.app"
-- first kill it
do shell script "kill -9 `ps aux | grep 'Indigo' |grep -v 'grep' | awk '{print $2}'`"
delay 2
-- check if killed
do shell script "ps aux | grep 'Indigo' "
-- restart
do shell script "open " & quoted form of theAPP
delay 2
-- check if restarted
do shell script "ps aux | grep 'Indigo' "

Posted on
Mon Dec 16, 2013 6:05 pm
jay (support) offline
Site Admin
User avatar
Posts: 18246
Joined: Mar 19, 2008
Location: Austin, Texas

Re: how to stop and restart indigo

There's a launchd doc here that does - though if you stop the server it should unload it. If the permissions are wrong I guess that could be an issue. Manually delete it then reboot:

~/Library/LaunchAgents/com.perceptiveautomation.IndigoServer2.plist

Note that's the Library folder that's in your home directory.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 16, 2013 6:06 pm
jay (support) offline
Site Admin
User avatar
Posts: 18246
Joined: Mar 19, 2008
Location: Austin, Texas

Re: how to stop and restart indigo

Your script is only killing the Indigo client app, not the server, so I'm not sure it's going to do what you think it does...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 16, 2013 6:51 pm
kw123 offline
User avatar
Posts: 8374
Joined: May 12, 2013
Location: Dallas, TX

Re: how to stop and restart indigo

ps aux | grep 'Indigo' |grep -v 'grep' | awk '{print $2}'

gives:
3783
3305
3329
5104
3548
3449
3448
3447
3446
3444
3443
3317
3316
3315
3314
3313
10122
that should be all indigo and Indigo pids!

Posted on
Mon Dec 16, 2013 7:02 pm
kw123 offline
User avatar
Posts: 8374
Joined: May 12, 2013
Location: Dallas, TX

Re: how to stop and restart indigo

deleting the file and rebooting cleared things up .. thank you

the kill does work. all indigo pids are gone and restart works nicely too.

is there a problem to start indigo this way i.e. start, kill and restart? then the "can not talk to application" messages are gone, at least for me..



Karl

Posted on
Mon Dec 16, 2013 7:07 pm
jay (support) offline
Site Admin
User avatar
Posts: 18246
Joined: Mar 19, 2008
Location: Austin, Texas

Re: how to stop and restart indigo

Well, you never want to kill -9 anything on a regular basis since that could leave things in an unexpected state - for instance, if it killed in the middle of a write to the filesystem. The better choice would be to not have Indigo start up upon login and rather just start it yourself manually.

(I only looked at the top of the script where you point to the client so I missed the other part)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Dec 16, 2013 8:12 pm
kw123 offline
User avatar
Posts: 8374
Joined: May 12, 2013
Location: Dallas, TX

Re: how to stop and restart indigo

is there a clean way in a script to start / stop / start indigo?

Posted on
Mon Dec 16, 2013 8:46 pm
matt (support) offline
Site Admin
User avatar
Posts: 21421
Joined: Jan 27, 2003
Location: Texas

Re: how to stop and restart indigo

Here is the script I use for shutdown the Indigo Server during debugging sometimes::

Code: Select all
#!/bin/sh
####################
# Copyright (c) 2008, Perceptive Automation, LLC. All rights reserved.
# http://www.perceptiveautomation.com
####################

# --------------------------------------------------------------
#
SERVER_NAME="IndigoServer.app"

LAUNCH_AGENTS_PATH="Library/LaunchAgents"
LAUNCHD_PLIST="com.perceptiveautomation.IndigoServer2.plist"

SERVER_KILLED_VIA_UNLOAD=0
SERVER_KILLED_VIA_SIGNAL=0

WEBSERVER_NAME="IndigoWebServer"

# Yuck. The installer calls us as root user, but if we make launchctl calls
# under root it won't find the user-specific plists (I think it should since
# we provide the full user path but it does everything under the root domain
# if the current user is root). We must extract out the real non-root user
# by finding the owner of the $HOME directory and use su on launchctl.
LAUNCHCTL_USER=`ls -ld "$HOME" | awk '{print $3}'`
RUNNING_USER=`id -un`

# --------------------------------------------------------------
#
appRunningCount()
{
   APP_RUNNING_COUNT=`ps -axww | grep "$1" | grep -v "grep" | grep -v "launchctl" | wc -l`
   return $APP_RUNNING_COUNT
}

getAppPID()
{
   APP_PID=`ps -axww | grep "$1" | grep -v "grep" | grep -v "launchctl" | awk '{print $1}'`
   echo $APP_PID   # echo, not return because PID will be greater than 255
}

waitForAppDeath()
{
   for (( index = 0 ; index < 10 ; index++ ))
   do
      appRunningCount "$1"
      if [ $? -eq 0 ]
      then
         return 0
      fi
      sleep 1
   done
   return 1
}

# --------------------------------------------------------------
#
killMainServer()
{
   appRunningCount "$1"
   if [ $? -eq 0 ]
   then
      echo "$1 was not running"
      return 0
   fi
   if [ -z "$LAUNCHCTL_USER" ]
   then
      echo "Failed to get owner of $HOME"
      return 0
   fi

   # First, try using launchctl to unload the plist. This only
   # works if launchctl was used to start the process.
   plistPath="$HOME/$LAUNCH_AGENTS_PATH/$LAUNCHD_PLIST"
   if [ -a "$plistPath" ]
   then
      echo "Unloading and disabling $plistPath"
      if [ "$LAUNCHCTL_USER" = "$RUNNING_USER" ]
      then
         launchctl unload -w "$plistPath"
      else
         echo "(forcing launchctl to run under user $LAUNCHCTL_USER)";
         su -m "$LAUNCHCTL_USER" -c "launchctl unload -w \"$plistPath\""
      fi
      if [ $? -eq 0 ]
      then
         echo "Unloaded $LAUNCHD_PLIST"
         waitForAppDeath "$1"
         if [ $? -eq 0 ]
         then
            echo "$1 was stopped via launchctl unload"
            SERVER_KILLED_VIA_UNLOAD=1
            return 0
         fi
         # else process is still running for some reason, fall through
         # to signal technique below
      fi
   fi
   
   # Next, use signals (start nice, then send SIGKILL) to try
   # shutting it down.
   APP_PID=`getAppPID "$1"`
   if [ -n "$APP_PID" ]
   then
      echo "Quitting $1 (SIGINT to $APP_PID)"
      kill -s TERM "$APP_PID"
      waitForAppDeath "$1"
      if [ $? -eq 0 ]
      then
         echo "$1 was stopped via signal"
         SERVER_KILLED_VIA_SIGNAL=1
         return 0
      fi

      echo "Quitting $1 (SIGKILL to $APP_PID)"
      kill -s KILL "$APP_PID"
      waitForAppDeath "$1"
      if [ $? -eq 0 ]
      then
         echo "$1 was killed via signal"
         SERVER_KILLED_VIA_SIGNAL=1
         return 0
      fi
      echo "Unable to kill $1"
      return 1
   fi
   echo "Bad PID returned ($APP_PID)"
   return 1
}

# --------------------------------------------------------------
#
killSecondaryProcess()
{
   appRunningCount "$1"
   if [ $? -eq 0 ]
   then
      echo "$1 was not running"
      return 0
   fi

   # Next, use signals (start nice, then send SIGKILL) to try
   # shutting it down.
   APP_PID=`getAppPID "$1"`
   if [ -n "$APP_PID" ]
   then
      echo "Quitting $1 (SIGTERM to $APP_PID)"
      kill -s TERM "$APP_PID"
      waitForAppDeath "$1"
      if [ $? -eq 0 ]
      then
         echo "$1 was stopped via signal"
         return 0
      fi

      echo "Quitting $1 (SIGKILL to $APP_PID)"
      kill -s KILL "$APP_PID"
      waitForAppDeath "$1"
      if [ $? -eq 0 ]
      then
         echo "$1 was killed via signal"
         return 0
      fi
      echo "Unable to kill $1"
      return 1
   fi
   echo "Bad PID returned ($APP_PID)"
   return 1
}

# --------------------------------------------------------------
#
killMainServer "$SERVER_NAME"

killSecondaryProcess "$WEBSERVER_NAME"

exit 0


And here is a script I use to start it:

Code: Select all
#!/bin/sh
####################
# Copyright (c) 2006, Perceptive Automation, LLC. All rights reserved.
# http://www.perceptiveautomation.com
####################

# --------------------------------------------------------------
#
SERVER_NAME="IndigoServer.app"

LAUNCH_AGENTS_PATH="Library/LaunchAgents"
LAUNCHD_PLIST="com.perceptiveautomation.IndigoServer2.plist"

# Yuck. The installer calls us as root user, but if we make launchctl calls
# under root it won't find the user-specific plists (I think it should since
# we provide the full user path but it does everything under the root domain
# if the current user is root). We must extract out the real non-root user
# by finding the owner of the $HOME directory and use su on launchctl.
LAUNCHCTL_USER=`ls -ld "$HOME" | awk '{print $3}'`
RUNNING_USER=`id -un`

# --------------------------------------------------------------
#
startMainServer()
{
   if [ -z "$LAUNCHCTL_USER" ]
   then
      echo "Failed to get owner of $HOME"
      return 0
   fi

   # First, try using launchctl to unload the plist. This only
   # works if launchctl was used to start the process.
   plistPath="$HOME/$LAUNCH_AGENTS_PATH/$LAUNCHD_PLIST"
   echo "Loading and enabling $plistPath"
   if [ "$LAUNCHCTL_USER" = "$RUNNING_USER" ]
   then
      launchctl load -w "$plistPath"
   else
      echo "(forcing launchctl to run under user $LAUNCHCTL_USER)";
      su -m "$LAUNCHCTL_USER" -c "launchctl load -w \"$plistPath\""
   fi
   if [ $? -eq 0 ]
   then
      echo "Started $SERVER_NAME"
   else
      echo "Failed to start via launchctl"
   fi
   return 0
}

# --------------------------------------------------------------
#
startMainServer

exit 0


Note the startup script uses launchd to start it up, which might present problems with Mavericks and AppleScript (despite the fact that launchd is the Apple approved way to launch services on boot/login). Your mileage may very. :-)

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests