5.0-Nano: Control

From The Uniform Server Wiki
Revision as of 19:33, 11 September 2009 by Ric (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

 

Control and alternatives

Uniform Server’s control architecture has been designed to be as flexible as possible.

It is recognised not everyone likes tray icons instead prefer batch file control this also prevents tray icon clutter.

This page covers control and control alternatives.

Batch files

Batch files found in folder UniServer\alternative_control offer this alternative control they can be run from that folder.

If you wish can be copied to the server’s top folder UniServer however in order to run they require minor modification as explained below.

The batch files can be tweaked to automatically close after a predefined time and or start UniTray. Details are provided under section Batch files and UniTray.

Top

Start_2.exe

Before looking at batch files you will have noticed file Start_2.exe this is an alternative to Start.exe.

Like Start.exe it starts UniTray however without the annoying pop-up to inform you it has done so.

If you would like to use this file copy it to folder UniServer and optionally

  • Delete Start.exe
  • Rename Start_2.exe to Start.exe choice is yours.

The only reason for deleting and renaming is to reduce clutter and keep things consistent.

Top

Common Core Control

Uniform Server has a single central control architecture located in folder UniServer\unicon\main all server control requests are passed to this core for processing.

Unitray, batch files and Apanel all make requests to this core it has the advantage of reducing complexity of external scripts.

Core control is designed around four CLI scripts these are split into two groups, standard program and service. Each group is further split into two files start-stop and install-uninstall service respectively. Two-tracker (Apache and MySQL) files control interaction between these.

Standard Program

Run as a Service

Tracker Files

start_servers.php

service_install_run.php

apache_tracker.txt

stop_servers.php

service_stop_uninstall.php

mysql_tracker.txt

Fig 1
Core Control;

 

location_tracker.txt

The above scripts access a common set of functions these have been written in vanilla PHP making them easier to understand and changeable.

Note: Location tracker is not interactive between the above scripts. It is shown only to emphasise its importance.

Top

Batch files

The esoteric nature of previous UniServer batch files have been addressed.

Batch file control is nothing more than a single line, which calls the appropriate PHP CLI script with an optional parameter.

The following batch files:

  • Start_Server.bat
  • Stop_Server.bat
  • Service_Install_Run.bat
  • Service_Stop_Uninstall.bat

Can be reduced to a single control line as shown respectively:

  • ..\usr\local\php\php.exe -n ..\unicon\main\start_servers.php
  • ..\usr\local\php\php.exe -n ..\unicon\main\stop_servers.php
  • ..\usr\local\php\php.exe -n ..\unicon\main\service_install_run.php
  • ..\usr\local\php\php.exe -n ..\unicon\main\service_stop_uninstall.php

Each line runs the PHP script interpreter php.exe two parameters are passed -n and the script to be run.

–n Instructs the interpreter not use a configuration file.

Top

Relocating batch files

After copying each batch file to folder UniServer you need to remove “..\” from each line.

Note “..\” means move up one level from the current location.

With the files already moved to this location the “..\” is redundant.

Hence the lines now look like this:

  • usr\local\php\php.exe -n unicon\main\start_servers.php
  • usr\local\php\php.exe -n unicon\main\stop_servers.php
  • usr\local\php\php.exe -n unicon\main\service_install_run.php
  • usr\local\php\php.exe -n unicon\main\service_stop_uninstall.php

Top

Script Parameters

An optional parameter passed to a script provides selection of various control options.

Defaults are used when a script is run with no parameter.

A parameter passed to a script overrides defaults.

Defaults can be changed in file UniServer\unicon\main\includes\config.inc.php

They are binary coded as follows (extract from config.inc.php):

 ###############################################################################
 # User Variables:
 # $server_standard - Controls server when run as a standard program 
 # $server_service  - Controls server when run as a service 
 #
 # $server_standard - Options are binary coded as follows:
 #                    Bit function
 # Apache         1   1 - Run Apache server 0 - no change ignore
 # Mysql          2   1 - Run MySQL  server 0 - no change ignore
 # Index page     4   1 - Start Index page  0 - no change ignore
 # MySQL Console  8   1 - Display console   0 - no change ignore
 # Cron          16   1 - Run cron          0 - no change ignore
 #
 # $server_service  - Options are binary coded as follows:
 #                    Bit function
 # Apache         1   1 - Run Apache as a service 0 - no change ignore
 # Mysql          2   1 - Run MySQL  as a service 0 - no change ignore
 # Index page     4   1 - Start Index page        0 - no change ignore
 #
 # Defaults: 
 # $server_standard = 7;
 # $server_service  = 7;
 ###############################################################################

Note: You add up the binary coded values to give the required default value.

Top

Example 1

If you wish to run only the Apache server when running as a standard program edit the batch files:

  • Start_Server.bat
  • Stop_Server.bat

Change the respective lines as follows:

  • usr\local\php\php.exe -n unicon\main\start_servers.php 1
  • usr\local\php\php.exe -n unicon\main\stop_servers.php 1

Top

Example 2

Apache and MySQL servers can be run without automatically displaying the index page using a parameter value of 3 as shown below:

  • usr\local\php\php.exe -n unicon\main\start_servers.php 3
  • usr\local\php\php.exe -n unicon\main\stop_servers.php 3

Note 1:

Changing the defaults in file config.inc.php affect Apanel, UniTray and batch files

(assumes batch files are not using parameters to override defaults).

Top

Batch files and UniTray

The batch files contain additional commands these have been disabled using “rem” (remark) removing the rem enables the command.

For example:

  • Changing: rem Start.exe
  • To: Start.exe starts UniTray when the batch file is run.

When a batch file is run its window remains open until a user presses any key.

This allows a user to view any error messages.

To have the window automatically close, disable the pause command using a “rem”

  • Change: pause
  • To: rem pause

Doing this you have no time to read any displayed text if you wish to read text enable the delay command by removing the “rem”.

  • Change: rem unicon\program\unidelay.exe 3
  • To: unicon\program\unidelay.exe 3

Note: The above sets a delays of three seconds change to your own preference.

Top

Example 1

This example uses UniServer\alternative_control\Start_Server.bat its current configuration looks like this:

..\usr\local\php\php.exe -n  ..\unicon\main\start_servers.php 1
rem Start.exe
rem ..\unicon\program\unidelay.exe 10
pause

Move the file to folder UniServer and edit to look like this:

usr\local\php\php.exe -n  unicon\main\start_servers.php 3
Start.exe
unicon\program\unidelay.exe 10
rem pause
  1. Only the MySQL and Apache server started (parameter 3)
  2. Start.exe - UniTray is started
  3. unicon\program\unidelay.exe 10 - A ten second delay allows text to be read
  4. rem pause - Pause is disabled hence window closes after 10 seconds

Top

Summary

Uniform Server uses a central control core with binary coded server control providing maximum flexibility with minimum complexity.

External control elements (batch files and UniTray) can override default options by passing a parameter to the core. UniTray uses this technique for starting both servers or single server control.

There are two additional scripts DtDNS and Cron designed to enhance control functionality.

  • DtDNS provides automatic IP updating for users that have an account this effectively turns a dynamic IP address into a static IP address.
  • Cron provides a background tick, on each tick runs a through a list of scripts defined by a user. This includes running the DtDNS script.

Top