First check whether a restart of the server is necessary. If it is, use a script that stops the services and starts them again in the correct order. VertiGIS provides the PowerShell script WebOfficeServerRestart.ps1 for this. It replaces the previous batch script GISServerRestart.bat.

Download: WebOfficeServerRestart.zip – the script WebOfficeServerRestart.ps1 and two templates for the Windows Task Scheduler (nightly restart, start after the server boots).

icon_comment

The script is intended for a single-server installation: ArcGIS Server, IIS, WebOffice FTS-Index, WebOffice extensions and Apache Tomcat run on the same machine.

If ArcGIS Server runs on a separate GIS server, run the script on the WebOffice 10.9 R5 web server with the parameter -SkipGisServer. Restart the GIS server separately beforehand, so that ArcGIS Server is available when Apache Tomcat starts.

Why PowerShell instead of a batch file?

The script does the same as the previous batch files: it stops the services and starts them again. But it checks every step instead of only waiting for fixed pauses. The script is a plain text file that you can open and read in a text editor; every section is commented. PowerShell is part of every Windows Server, nothing needs to be installed. You only have to adapt the configuration block at the beginning (section CONFIGURATION); the rest stays unchanged.

•net stop / net start: the script also waits until the service has actually stopped or started, and logs it if that fails.

•timeout /t 3600 (fixed pause): the script waits until ArcGIS Server or Apache Tomcat answer, which is usually much shorter.

•taskkill /f: only if Apache Tomcat has not stopped after 180 seconds.

•start https://.../synadmin?...: POST request without a browser, no password in the script.

•Output that gets lost or overwritten: one log file per run with time stamps, the duration of each step and the total run time, exit code 1 on errors.

Try the script with a dry run first. It checks the configuration (services found? addresses reachable? password correct?) and logs what a real run would do. Nothing is stopped, started or changed; the password is only checked with a read-only status request (action=status_fts_index):

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\WebOfficeServerRestart.ps1" -DryRun

-ExecutionPolicy Bypass applies to this one call only. The execution policy of the server is not changed.

Always call the script through powershell.exe as shown in the examples. Unlike a batch file, a .ps1 file cannot be started directly in a command prompt (cmd): Windows only opens it in an editor, the script does not run.

Order

The script first stops the services that use other services, and starts all of them again in reverse order:

1.Stop: Apache Tomcat, WebOffice extensions, ArcGIS Server, WebOffice FTS-Index, World Wide Web Publishing Service, IIS Admin Service

2.Start: IIS Admin Service, World Wide Web Publishing Service, WebOffice FTS-Index, ArcGIS Server, WebOffice extensions, finally Apache Tomcat

3.Optional: recreate the full-text search of the configured WebOffice 10.9 R5 applications

Instead of fixed pauses, the script waits after each step until the service has actually stopped or started. After ArcGIS Server has started, it waits for a successful response of the ArcGIS Server health check; after Apache Tomcat has started, for an HTTP response. Every step has an upper time limit. Apache Tomcat is only killed if it does not stop normally within 180 seconds. Services that are not installed on the machine are skipped with a warning.

Parameters

•-DryRun: dry run, checks the configuration and logs what would be done. Changes nothing.

•-SkipGisServer: leaves the services of the GIS server (ArcGIS Server, WebOffice extensions) untouched. For installations where ArcGIS Server runs on a separate machine.

•-StartOnly: runs only the start part, e.g. after a restart of the server machine.

•-SkipFullTextSearch: does not recreate the full-text search, even if applications are configured for it (see below).

•-LogDir: folder for the log files (default: subfolder Logs next to the script). Each run writes one log file; files older than 30 days are deleted. The columns are separated by tabs: time, run time so far (Elapsed), time since the previous line (Step), status and message; the last lines show the total run time. To evaluate the times, select the whole content in the editor and paste it into Excel – the columns are split automatically.

Adapting the script

Before using the script for the first time, adapt the configuration block at its beginning to your server: the names of the services (e.g. Tomcat11), the URLs for the health checks of ArcGIS Server and Apache Tomcat, and the time limits. The script uses the service name (column Name, e.g. W3SVC). Unlike the display name (World Wide Web Publishing Service, on a German Windows WWW-Publishingdienst) it does not depend on the Windows language. The following PowerShell command lists the names of the services:

Get-Service | Format-Table Name, DisplayName

The ArcGIS Server health check defaults to https://localhost:6443/arcgis/rest/info/healthCheck?f=json (ArcGIS Server 10.7 or later). If this port is blocked, the address via the ArcGIS Web Adaptor can be used instead, e.g. https://server/webadaptor/rest/info/healthCheck?f=json. The dry run shows whether the address is reachable.

Recreating the full-text search (optional)

If a Full-Text Search is configured, the script can recreate the subindexes of one or more WebOffice 10.9 R5 applications after Apache Tomcat has started. Enter the addresses of the applications in the configuration block under $FtsApplications, e.g. 'https://server/WebOffice'. $FtsSubindex defines which subindexes are recreated (default ALL_OUTDATED).

For each application the script sends a Batch Administration Request with action=recreate_fts_index as a POST request. The password therefore appears neither in a URL nor in the access logs of Apache Tomcat nor in the log of the script. If an application does not yet answer with OK because it is still initializing, the script repeats the request for up to 15 minutes.

The script reads the encrypted password of the user batchadmin for each application from its application configuration: attribute pwd of BATCHADMIN_USER in WEB-INF\classes\configuration\application_config.xml. So every application uses its own password, nothing is stored in the script, and a change in WebOffice author standalone under Application configuration > WebOffice > Admin user for batch requests applies at once, see chapter Admin User for Batch Requests.

The script finds the folder of the application the same way as Apache Tomcat: via a context file conf\Catalina\localhost\<application>.xml or a Context entry in server.xml (e.g. when the application is outside webapps, as in GEONIS installations), otherwise in the folder webapps. It reads the Tomcat folder from the Tomcat service. If the configuration is somewhere else, give it directly for this application:

@{ Url = 'https://server/WebOffice2'; Config = 'D:\GEONIS\WebOffice2\WEB-INF\classes\configuration\application_config.xml' }

The dry run shows for each application which file the password was read from, and checks it with a read-only status request. The parameter -SkipFullTextSearch skips this step for a single run.

Windows Task Scheduler

Create one task for the nightly restart of the services. It runs as SYSTEM with highest privileges, so no password of a user account has to be stored:

Program: powershell.exe

Arguments: -NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\WebOfficeServerRestart.ps1"

Instead of creating the task manually, you can import the template WebOfficeServerRestart_Nightly.xml from the download (Task Scheduler > Action > Import Task). It runs the script daily at 02:00 from C:\Scripts. Both templates run as SYSTEM, the import does not ask for a password. Adapt the time and the script path in the import dialog. The template WebOfficeServerRestart_Startup.xml is for the start after booting (see below). Alternatively by command:

schtasks /create /xml "WebOfficeServerRestart_Nightly.xml" /tn "WebOffice\WebOffice Server Restart"

After the import, check that the task points to the right script path. Even with a wrong path schtasks /run reports "SUCCESS", but the script does not start. When imported in the Task Scheduler, the task is named like the file, e.g. WebOfficeServerRestart_Nightly:

schtasks /query /tn "WebOffice\WebOffice Server Restart" /v /fo list | Select-String "Task To Run","Run As User","Start In"

Correct the path in the properties of the task under Actions or with PowerShell (as administrator):

Set-ScheduledTask -TaskPath "\WebOffice\" -TaskName "WebOffice Server Restart" -Action (New-ScheduledTaskAction -Execute powershell.exe -Argument '-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\WebOfficeServerRestart.ps1"' -WorkingDirectory C:\Scripts)

If an error occurs, the script ends with exit code 1. The Task Scheduler shows this as the result of the last run.

If the server machine is also restarted regularly, schedule this at a different time than the nightly restart of the services. For the start after booting, create a task with the trigger At startup and the additional argument -StartOnly. Then set the startup type of the services Apache Tomcat and WebOffice extensions to Manual, so that only the script controls the order.

icon_cross-reference

•Further administration requests (e.g. reloading an application) are described in chapter Batch Administration Request. Send them as POST requests and do not store passwords in plain text in a script.

•See also chapter Problems during project initialization.