Starting and Stopping the SAS/SHARE Server
Finally, the server must be started up on the remote system. Remember that a database engine is a background process that runs continually on the server listening for connection attempts.
Consequently, a SAS data server program has to be running in order for the clients to have something to connect to. PROC SERVER is used to start the server, as illustrated in the following example:
Example 4.1 Sample Program to Start the SAS/SHARE Server
******************************************************;
***** start SAS/SHARE server on local host ******;
***** system administrator password: system ******;
***** user password: user *****;
***** authentication is on ******;
******************************************************;
proc server id=shr1 oapw=system uapw=user
authenticate=required;
run;
Four parameters are illustrated:
id – the required service name defined in the services file.
oapw – an optional administrator password; if included it must be supplied to stop the server.
uapw – an optional user password; if included it must be supplied to connect to the server.
authenticate – a choice of either optional or required; if required is specified, the user must supply a valid user ID and password in order to connect to the server, and TCPSEC must be set in the configuration file as illustrated in the previous section.
To stop the server, the OPERATE procedure is used:
Example 4.2 Stop the SAS/SHARE Server
*****************************************************;
***** stop SAS/SHARE server on local host *****;
*****************************************************;
proc operate serverid=shr1 sapw=system uid=_prompt_;
stop server;
run;
Three parameters are included on the procedure statement:
serverid – the required service name defined in the services file.
sapw – an operator password specified when the service was started (the same as the oapw in the startup script).
uid – a valid login name and password for the system that must be supplied if
authentication is required. The argument value _prompt_ displays a pop-up window for user ID and password; otherwise the value must be hardcoded in the program file, which is a security risk.
PROC OPERATE takes a number of options including stop (shown in Example 4.2), display server (show the status of a named service),quiesce (refuse any new connections), and start (restart a quiesced service).
The process for starting a server is different on UNIX and Windows, although the underlying concept is the same.
Assuming that the program shown in Example 4.2 has been saved as sharesrv.sas, you would start the server on UNIX by typing the following shell command:
nohup sas -noterminal -rsasuser –sysin sharesrv.sas &
Running the command with nohup (no hang up) ensures that you can log out and the server will continue to run. Appending an ampersand (&) causes this program to run in the background. (It is of course possible to add the script to the init.d directory so that it will be automatically started when the server reboots. You will need to convince your system administrator to do this for you, unless of course you are the sysadmin.)
Chapter 4 Remote Access to SAS 81
Managing SAS/SHARE as a Windows Service
SAS recommends that the server be installed as a Windows service so that it will automatically restart if the system needs to be restarted. There are three ways to accomplish this, depending on the combination of SAS components available on the server.
SAS Service Configuration Utility
Note that this utility is available only on Windows NT/2000/XP; it is not available for UNIX or Windows 95/ 98/ME, since these do not support the concept of Windows application services.
Once this tool has been installed, go to Start X Programs X SAS X SAS 9.1 Utilities X SAS Service Configuration Utility. Something like the following screen should appear:
Display 4.3 Installing a SAS/SHARE Service Using the SAS Service Configuration Utility
You need to fill in only the first four parameters (see the documentation available by clicking the Help button on the form):
1. Service Name - the internally registered name of the service being installed.
2. Display Name - the name of the installed service as it is displayed.
3. Start Type - the method for starting the service; the options are Manual or Automatic.
Selecting the latter will start the service when the Windows server is rebooted; otherwise the service must be started from the Service Control Manager (see Display 4.4 below).
4. Service Path – the path to the location of the SAS program to start the service, plus any command-line parameters required by the service.
The only hard one is the Service Path. In Display 4.3, the SAS executable is located in the directory E:\sas and the server startup program is in E:\sas\share. Consequently the arguments to the service path are the following:
E:\sas\sas.exe -noterminal -rsasuser -sasuser "C:\temp"
-unbuflog -log E:\sas\share\sharesrv.log
-sysin E:\sas\share\sharesrv.sas
In other words, run the SAS program sharesrv.sas to start the server, do not display a terminal window, open a temporary SASUSER.PROFILE catalog, do not buffer the SAS log, and write the log out to the same folder as the input.
Click OK in the screen and the server will be installed as a Windows service. In this way it will be started when the system reboots and can be managed from the Windows Service Control Manager console.
If the service does not start automatically, it can be started manually from the Windows Services Manager application. Right-click the My Computer icon and select Manage X Services and Applications X Services and look for SAS Share Server SHR1 as shown in Display 4.4. Click Start the service to start the Share server.