Skip to main content

[Migrated content. Thread originally posted on 14 December 2011]

I'm running NetExpress/Studio 6.
Is there a place to add a script when ESMAC is terminating? I do NOT want to cause ES to terminate but have a script run whenever ES does close down. Is there some place to specify this request within microfocus server admin page(s)??


#EnterpriseDeveloper

[Migrated content. Thread originally posted on 14 December 2011]

I'm running NetExpress/Studio 6.
Is there a place to add a script when ESMAC is terminating? I do NOT want to cause ES to terminate but have a script run whenever ES does close down. Is there some place to specify this request within microfocus server admin page(s)??


#EnterpriseDeveloper
follow the path in documentation
Enterprise > Server Enterprise Edition 6.0 ServicePack 2 WebSync 1 for Windows > Enterprise Server > Enterprise Server Configuration and Administration > Configuring and Administering Enterprise Server Instances > Connecting to a Server Instance


Using Start and Stop Scripts
You can supply start and stop scripts to take additional actions before or after starting or stopping an enterprise server. You must include the casstart command in your start script, and the casstop command in your stop script. If you omit them the server will not actually be started or stopped.
The Directory Server sets some environment variables in the scripts' environment, which you can use in your scripts:
ES_HOME Server work directory (location of log files); this comes from the System Directory field on the Add Server or Edit Server > Properties > General page.
ES_SERVER Server name (note that Enterprise Server will use this as the server name if no -r switch is specified on casstart or casstop).
ES_WORKING_MODE The working mode of the server. This indicates whether the server is to run 32-bit or 64-bit applications.
MFDS_PORT The port on which the Directory Server listens (usually 86).
For example, the start script could be used to set environment variables for the server, as follows;
set MY_VARIABLE=value
rem start the enterprise server
echo Enterprise Server %ES_SERVER% is starting
casstart
where value is the value of the environment variable.
If your stop script contains commands that should only be executed after the server has stopped completely, it should pause after executing casstop until thecascd process for that server has exited. This is because the casstop command returns before the server has actually finished shutting down. You would need third-party tools to do this on Windows.
Then you could back up the log files or perform other tasks that should only be started after the server finishes shutting down.
When you click the server's Start or Stop button, the commands that you specify are used to generate a Windows batch file, which is then executed.
You can also create an "On server not responding" script. This script will be executed when all of the running communications processes for a server have entered the "Not Responding" state. That might indicate that the server is hung or has crashed, or it might result from network connectivity problems between the Directory Server and the enterprise server (if they run on different systems). You can use this script to notify a system administrator of the problem.
You specify start, stop and "On server not responding" scripts on the Edit Server > Properties > Advanced page.

[Migrated content. Thread originally posted on 14 December 2011]

I'm running NetExpress/Studio 6.
Is there a place to add a script when ESMAC is terminating? I do NOT want to cause ES to terminate but have a script run whenever ES does close down. Is there some place to specify this request within microfocus server admin page(s)??


#EnterpriseDeveloper
bikerbob originally wrote:
I'm running NetExpress/Studio 6.
Is there a place to add a script when ESMAC is terminating? I do NOT want to cause ES to terminate but have a script run whenever ES does close down. Is there some place to specify this request within microfocus server admin page(s)??


I replied to this yesterday, but apparently my reply was lost.

First, I think there's some confusion here. ESMAC does not "terminate". It's part of the administrative interface to an ES region. So I assume you're asking about executing a script when a region is shut down.

To have a script executed when a region is shut down using the GUI, specify it in the MFDS (Enterprise Server Administration) GUI. Edit the region, select the Properties tab, select the Scripts tab under that. Enter the text of your script in the Stop Script text area, check the Enabled box, and click OK to save your changes.

To have a script executed when a region is shut down using the command line, simply write an appropriate script and use that to stop the region.

On Windows, your script will be executed as a .cmd file; on Unix, it will be exec'd as any other script file (so you can specify an interpreter with a "#!" line).

Your script should run casstop in order to actually stop the region.

An (untested) example for Windows:

msg * "ES region %ES_SERVER% shutting down"
casstop /r%ES_SERVER% %ES_CMD_OPTIONS%

[Migrated content. Thread originally posted on 14 December 2011]

I'm running NetExpress/Studio 6.
Is there a place to add a script when ESMAC is terminating? I do NOT want to cause ES to terminate but have a script run whenever ES does close down. Is there some place to specify this request within microfocus server admin page(s)??


#EnterpriseDeveloper
Thank you for your responses. You are correct - I am interested in when the region shutsdown as opposed to ESMAC. I have tried this using the "stop". However, I get an invalid stop type error and the region does not shutdown. I have tried many variations of the command to no avail. I have tried a bat, a cmd, rex and python and all get the same error. the command being casstop /stcp:172.31.20.159:1449 /i. I have tried /f but no shutdown. any suggestions?

[Migrated content. Thread originally posted on 14 December 2011]

I'm running NetExpress/Studio 6.
Is there a place to add a script when ESMAC is terminating? I do NOT want to cause ES to terminate but have a script run whenever ES does close down. Is there some place to specify this request within microfocus server admin page(s)??


#EnterpriseDeveloper
Thank you for your responses. You are correct - I am interested in when the region shutsdown as opposed to ESMAC. I have tried this using the "stop". However, I get an invalid stop type error and the region does not shutdown. I have tried many variations of the command to no avail. I have tried a bat, a cmd, rex and python and all get the same error. the command being casstop /stcp:172.31.20.159:1449 /i. I have tried /f but no shutdown. any suggestions?

[Migrated content. Thread originally posted on 14 December 2011]

I'm running NetExpress/Studio 6.
Is there a place to add a script when ESMAC is terminating? I do NOT want to cause ES to terminate but have a script run whenever ES does close down. Is there some place to specify this request within microfocus server admin page(s)??


#EnterpriseDeveloper
bikerbob originally wrote:
Thank you for your responses. You are correct - I am interested in when the region shutsdown as opposed to ESMAC. I have tried this using the "stop". However, I get an invalid stop type error and the region does not shutdown. I have tried many variations of the command to no avail. I have tried a bat, a cmd, rex and python and all get the same error. the command being casstop /stcp:172.31.20.159:1449 /i. I have tried /f but no shutdown. any suggestions?


There's no /s or /i option for casstop. Remove those two parameters. See the sample I provided for a casstop command line that should work.

On Windows, any script text you supply in a region's configuration is executed as a .cmd file. To use a different scripting language (such as Python), you'd have to supply script text that executes a script written in the other language (eg "python es-shutdown.py").

[Migrated content. Thread originally posted on 14 December 2011]

I'm running NetExpress/Studio 6.
Is there a place to add a script when ESMAC is terminating? I do NOT want to cause ES to terminate but have a script run whenever ES does close down. Is there some place to specify this request within microfocus server admin page(s)??


#EnterpriseDeveloper

okay. I can manually run a script to stop the region. However the problem NOW is that the script is NOT being executed from the "scripts/stop script" window. My statement looks like this:

CALL "F:\\cfw_test\\scripts\\test_stop_script.cmd"

I can open a DOS command window and run this script and it works but not from microfocus.

Is "CALL" the right verb to use?? I cannot find any doc or what to use to start the script.

I've tried start, run cmd and nothing seems to get the window to execute the script.


[Migrated content. Thread originally posted on 14 December 2011]

I'm running NetExpress/Studio 6.
Is there a place to add a script when ESMAC is terminating? I do NOT want to cause ES to terminate but have a script run whenever ES does close down. Is there some place to specify this request within microfocus server admin page(s)??


#EnterpriseDeveloper

[quote][/quote]

okay. I can manually run a script to stop the region. However the problem NOW is that the script is NOT being executed from the "scripts/stop script" window.

You have the "Enabled" checkbox next to the label "Stop script" checked, right?

And you're stopping the region using the GUI interface (the Control tab of MF Enterprise Server Administration)? The configured scripts are executed by the GUI - if you run the "casstop" command directly, from a command window or similar, the scripts won't be executed. From the command line, you have to run your script directly.

[quote]My statement looks like this:[/quote]

CALL "F:\\cfw_test\\scripts\\test_stop_script.cmd"

I can open a DOS command window and run this script and it works but not from microfocus.

Is "CALL" the right verb to use?? I cannot find any doc or what to use to start the script.

When you ask MF Enterprise Server Admin to stop the server, the text that's in the script area is written to a temporary file with a ".cmd" extension. Then MFDS executes cmd.exe, pointing it at the temporary file. So the script can include anything a Windows cmd file can contain. (On UNIX, the process is similar, except that MFDS will execute the temporary file with execv, so the processing program can be specified with an interpreter comment on the first line of the script.)

So the CALL command should work. If it's the only or last statement in the script, you can also just run your test_stop_script.cmd directly, rather than using CALL. (CALL just lets cmd return to the calling script when the called script exits.)

[quote][/quote]

I've tried start, run cmd and nothing seems to get the window to execute the script.

Is F: a local drive or a mapped network drive? The MFDS process (which is what will be executing your script) is installed to run as a service under the LOCAL_SYSTEM account, by default, which means it doesn't have access to network drives. If F: is a local drive, you may want to check file permissions to confirm that LOCAL_SYSTEM has read access to the script file.

You can also try setting the journal level in MFDS to "Debug" (Options, Journal tab, select "Extra debug messages"). Then try to stop the server, and see whether there are any explanatory messages in the journal.