# Running the Server

> Source: https://manual.pvxplus.com/windx/application-server/running-the-server

The operation side of the Application Server is handled by the ***server daemon***, a platform-independent PxPlus program called **\*appserv/server**. This program is designed to run as a background task and is responsible for:

- Listening for client/server connections
- Responding to requests
- Launching new sessions
- Moving traffic between the client- and server-side processes

The Start-In directory for the server daemon is an important consideration. When the daemon launches new processes (applications), it will start them in the same directory in which the server daemon was started. This occurs unless either the application requested had a designated Start-In directory, or the client requested a specific Start-In directory.

Associated files should be given a path that is relative to the Start-In directory of the server daemon.

## Command Line Syntax

The server daemon Command line syntax is described as follows:

|  |  |  |
| --- | --- | --- |
|  | In ***Windows***: | *PVXpath$* \[*state*\] \[*ini*\] **\*appserv\\server** **–ARG** *ServerName* |
|  | In ***UNIX/Linux***: | *PVXpath$* **\\\*appserv/server –ARG** *ServerName* |

***Where:***

|  |  |  |
| --- | --- | --- |
|  | *PVXpath* | Path to PxPlus. |
|  | *state* | Option setting for governing the initial WindX window:<br>***null*** - Normal window  <br>***-mn*** - To start minimized  <br>***–hd*** - To start hidden |
|  | *ini* | Optional user-defined INI file (or *..\\Lib\\\_appserv\\apssrv.ini*). Do ***not*** use a **\*** in the INI path, as PxPlus does not resolve them as it does program names. ***(Windows Only)*** |
|  | *ServerName* | Name of a server defined in the configuration. Case insensitive. May be quoted. |

## Starting the Server Daemon - Examples

The following are examples of a Start command for an Application Server daemon:

***Under Windows***

If the *Start-In Directory* is C:\\PxPlus:

C:\\pxplus\\pxplus.exe -mn "C:\\pxplus\\Lib\\\_appserv\\appsrv.ini"  
 \*appserv\\server -ARG "MainServer"

***Under UNIX/Linux***

***Method 1:*** From a Shell script

```
#!/bin/sh
TERM=ansi; export TERM
cd /usr/pvx
/usr/pvx/pvx \*appserv/server -ARG MainServer </dev/null >/dev/null 2>&1
```

***Method 2:*** Directly from */etc/inittab*. This uses "/ "as its starting directory.

pvd1:2345:respawn:/usr/pvx/pvx \\\*appserv/server -ARG MainServer  
 \</dev/null >/dev/null 2>&1

***Method 3:*** From the */etc/rc* set of directories ***(Linux Method)***

Create a file in */etc/init.d*. The simplest method is to copy an existing script from that directory and modify it to start the above command line. The script should contain the **START( )** and **STOP( )** functions required. Use symbolic links in the */etc/rc?.d* directories to link to your script.

## Stopping the Server Daemon

***Under Windows***

Right click on the PxPlus Application Server icon for the server daemon in the Windows Taskbar, then select *Close* or *Interrupt*.

***Under UNIX/Linux***

Send a SIGBREAK to the server daemon process.

***Example:***

Kill -2 *pid*

***Where:***

*pid* is the process ID of the server daemon.
