Shell script to shut down and restart Indigo

Posted on
Sun Oct 20, 2019 3:10 pm
mundmc offline
User avatar
Posts: 599
Joined: Sep 14, 2012

Shell script to shut down and restart Indigo

I am still having problems with the IWS abruptly stopping. Jay saved me with these two commands, that allow me to ssh in to restart it:

Code: Select all
/usr/local/indigo/indigo-stop
/usr/local/indigo/indigo-start


Breaking new ground, I made a simple script to run them more easily, or from an email trigger (as these continue to function, I think):
Code: Select all
#!/bin/bash
# script to restart indigo server

/usr/local/indigo/indigo-stop
sleep 20
/usr/local/indigo/indigo-start


I can't for the life of me get it to run from the "Run Shell Script" Action Group window.

It's executable, and I can run it by typing into terminal
Code: Select all
./StopAndStartIndigoServer


Perhaps I am entering the path wrong?
Code: Select all
/Library/Application\ Support/Perceptive\ Automation/shell\ scripts/StopAndStartIndigo.sh


Thoughts?
PS- if there is a way to restart JUST the web server, that would be awesome.

Posted on
Sun Oct 20, 2019 3:47 pm
FlyingDiver offline
Posts: 3608
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Shell script to shut down and restart Indigo

I suspect it's not working because Indigo is waiting for the shell script to complete before it actually shuts down.

Try using a Python script that does a subprocess command to run the restart script, which doesn't wait for the script to continue. And maybe add a sleep for a couple seconds at the start of the script so it doesn't try to run the shutdown until the Python script has completed.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Oct 20, 2019 7:31 pm
mundmc offline
User avatar
Posts: 599
Joined: Sep 14, 2012

Re: Shell script to shut down and restart Indigo

Thank you for the response. I am unclear if I understand- I use a python script to run the shell script as listed? Does it matter if the python script is run IN indigo or separately (I assume separately, but unsure why)?

Posted on
Sun Oct 20, 2019 7:50 pm
FlyingDiver offline
Posts: 3608
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Shell script to shut down and restart Indigo

mundmc wrote:
Thank you for the response. I am unclear if I understand- I use a python script to run the shell script as listed? Does it matter if the python script is run IN indigo or separately (I assume separately, but unsure why)?


You can use a standard embedded (not external) Python script. The idea is that you want to spawn off the shell script into it's own process that will run without Indigo waiting on it (or vice versa). There's probably a way to do it just in one shell script, but I'm not that good a shell programmer.

Something like:

Code: Select all
import subprocess
subprocess.Popen(["/path/to/shell/script"])

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Oct 20, 2019 11:05 pm
mundmc offline
User avatar
Posts: 599
Joined: Sep 14, 2012

Re: Shell script to shut down and restart Indigo

Thank you. It’s funny, I was surprised to read Indigo would wait for a response from the script, especially considering the script was stopping and restarting Indigo. I hope I’m getting this right. I guess I thought every external script had it’s own process, but I really don’t get basic unix/linux stuff, yet at least. I’ll try the python subprocess approach.

Posted on
Mon Oct 21, 2019 5:26 am
FlyingDiver offline
Posts: 3608
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Shell script to shut down and restart Indigo

I think that Indigo is trying to "clean up" when it's told to shut down, so it's waiting on child processes that it started to complete. It doesn't know that one of them is a script that's asking for the shutdown.

But this is all speculation, I've never seen the shutdown code in Indigo.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Mon Oct 21, 2019 10:44 am
jay (support) offline
Site Admin
User avatar
Posts: 15876
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Shell script to shut down and restart Indigo

Make sure that you don't have the Store result in variable option selected, as that will explicitly wait until the script is finished in order to get the return value. Otherwise, the action shouldn't be holding up the server shutdown because in that configuration it doesn't wait for the script to finish running (run shell script runs in a separate process).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Oct 21, 2019 11:16 am
jay (support) offline
Site Admin
User avatar
Posts: 15876
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Shell script to shut down and restart Indigo

Ok, a little more testing shows that you probably can't call indigo-stop directly from the Run Shell Script action (even indirectly). That script does some snooping to get the user that owns the process which I think doesn't work when run from the Run Shell Script command (because of the shell environment).

All this is, however, just treating the symptom rather than getting to the bottom of why IWS stopping. I don't recall the context of your original request - did we discuss that further? Solving that seems like the best course of action since it's the root problem.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Nov 14, 2019 5:05 pm
mundmc offline
User avatar
Posts: 599
Joined: Sep 14, 2012

Re: Shell script to shut down and restart Indigo

This is helpful.

I have yet to make any observations about why the IWS is stopping when it does. This is, in part, because I don’t know it’s down until I am loading up a control page. Interestingly, the problems has not flared up for over a week right now, no clue why not.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest