The following procedure should always be followed to stop the SystemWeaver Server Application and then start it again, e.g., after a database backup restoration or upgrade.


Confirm No Clients are Connected to Server

This can be done by notifying all users in advance by email, telling them to log out before a specific time of day. In case any clients remain connected anyway, e.g., due to the user being absent, the following steps can normally be performed with low risk for loss of data, since most client operations are performed momentarily and atomically. Administrators can log in using the swAdmin2 client and see a list of current sessions on the Logged on page. 


Confirm Server Application is Not Busy Performing Tasks

This can be done by looking in the log window of server applications with a GUI, by using the Windows Task Manager or by looking in the log file. Note that some exceptional operations may take excessive time and may cause the server to appear inoperable from the perspective of the clients, when in fact it is busy performing a task that should not be interrupted.


Note: A special case that should be considered carefully is when a SystemWeaver server appears to have stopped, due to memory problems. In such cases, the server may continue to execute, at a very slow rate. The normal method of detecting activity, to look at the CPU value, will not be effective. Instead, you should look at the CPU Time value during a period of minutes.


Make a Copy of the Original Database

Next, make sure you have a copy of the database that was used by the server prior to beginning this process. This is to avoid that the file is overwritten by mistake. Give the copy a suitable name, e.g., appending the file name with current date. For Oracle or SQL Server databases, refer to documentation from Oracle or Microsoft. For SQLite database files, see How to Back Up the Database.


Make a Copy of the Log File 

The next step is to make a copy of the log file (typically named "swServer.log"). This is to avoid that the log file is overwritten when the server is restarted, in case the 'append' option is not used (see Format of .props File in the Help for more information). Check the 'Date Modified' to make sure it's the right file. Give the copy a suitable name, e.g., appending the current date.


Stopping the SystemWeaver Server Application

All SystemWeaver servers are designed to be robust and able to cope with unexpected termination. However, since the behavior may depend on the specific database manager in use, specific behavior of the operating system, and the network connection, a SystemWeaver server should always be stopped in a controlled fashion since the database may need to perform actions as part of the shutdown.

Running Executable Directly

Server Applications with a GUI, like the swTestServer, have Stop buttons for the purpose of stopping the server in a controlled way.

The swDBServer, which runs with a minimal GUI, is stopped in a controlled way with the Window Exit button.

Running as a Windows Service

Server applications running as services by the swServerMonitorService, should be stopped by the Windows Services tool (or see the SystemWeaver as a Service section of the Help). When the server is stopped this way, any connected clients will automatically be disconnected. The swServerMonitorService sends a stop request to the server application, but in case the application does not stop within 10 seconds, the monitor will terminate the application anyway. Thus, you should always confirm that the server application is not busy performing tasks.

Server applications running as background Windows processes, without any service active, must be stopped by the Windows Task Manager. Note that in this case there is no support for a controlled shut down, so confirm that no clients are connected to the server and that the server application is not busy performing tasks.


Note: Make sure the server has stopped until the next steps are performed. Depending on the specific situation, the time for this may vary so the Windows Task Manager should always be used to confirm that the server process has terminated.


Perform the Repair, Upgrade or Restoration of the Database

Now that you have stopped the server and made a copy of the database, proceed with your work. For example, to restore to a backed-up file, delete the original database file (the one you made a copy of in step 1 above) and rename the backed-up file to the name of the original database file. It is recommended to make a copy of the text in the log window (select+copy) for future references. Start the SystemWeaver server application again, and check in the log window or file that no problem is detected during the start-up.