eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'WebServerStartup':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: WebServerStartup


Inheritance:

   Object
   |
   +--StandaloneStartup
      |
      +--WebServerStartup

Package:
stx:projects/webServer
Category:
demos-Standalone-applications
Version:
rev: 1.66 date: 2018/05/16 09:11:20
user: cg
file: WebServerStartup.st directory: projects/webServer
module: stx stc-classLibrary: webServer

Description:


a non-graphical demo application;
when built, it creates an executable which starts
a webServer (HTTPServer - comparable to apache).

Command-line arguments:
    see WebServerStartup usageLines asString
[build with:]
    cd projects/webServer; make

[execute with:]
    cd projects/webServer; webServer


Class protocol:

actions
o  setServerSettingsFor: aServer fromArguments: argv

helpers
o  redirectStandardStreams

o  serverForSettingsFilename: aFilename

startup
o  allowDebugOption
enable/disable the --debug startup option.
The default is now false, so standAlone apps are closed by default.
Can be redefined in subclasses to enable it

o  isHeadless

o  main: argv
double stack size because of the stc needs more stack in standalone app

o  usage


Instance protocol:

actions
o  addRunningServer

o  removeRunningServer

initialization
o  initialize

startup
o  createServerFromArguments:
start server and search for some parameters

o  setupErrorHandler
NoHandlerError emergencyHandler:[:ex|
|activeProcess|

activeProcess := Processor activeProcess.
Timestamp now errorPrint.
(': unhandled exception for <', activeProcess name, '> [', ex description, ']') errorPrintCR.
(activeProcess name startsWith:'HTTPServer') ifTrue:[

o  startServerFromArguments:

o  startServersFromArguments:
|startIndex endIndex serverArgs|

startIndex := 0.
[
endIndex := argv indexOf:$, startingAt:startIndex + 1.
endIndex ~~ 0 ifTrue:[
serverArgs := argv copyFrom:startIndex + 1 to:endIndex - 1.
] ifFalse:[
serverArgs := argv copyFrom:startIndex + 1.
].
self startServerFromArguments:serverArgs.
startIndex := endIndex.
] doUntil:[endIndex = 0].

self setupErrorHandler.

processCountSema count == 0 ifTrue:[
'WebServerStartup [info]: no server was started. Did you specify a correctly stored settings file as argument?' errorPrintCR.
].



Demonstration:


    WebServerStartup main


Examples:


check from non-headless Smalltalk; look at the terminal output Example 1:view the help file
    | args |
    args := OrderedCollection new.
    args add:'--help'.

    self new initialize startServersFromArguments:args.
Example 2:start from settings file
    | args |
    args := OrderedCollection new.
    args add:'--useFile'; add:'./webServerSettings.xml'.

    self new initialize startServersFromArguments:args.

Example 3:start from settings file and overwrite port
    | args |
    args := OrderedCollection new.
    args add:'--useFile'; add:'./webServerSettings.xml'.
    args add:'--port'; add:'8082'.

    self new initialize startServersFromArguments:args.
Example 3:start from settings file and overwrite logFile
    | args |
    args := OrderedCollection new.
    args add:'--useFile'; add:'./webServerSettings.xml'.
    args add:'--log'; add:'/tmp/foo'.

    self new initialize startServersFromArguments:args.
Example 4:start two servers in one image
    | args |
    args := OrderedCollection new.
    args add:'--useFile'; add:'./webServerSettings_8081.xml'.
    args add:self webServerSettingsSeperator.
    args add:' --useFile'; add:'./webServerSettings_8080.xml'.

    self new initialize startServersFromArguments:args.

Example 4:start two servers in one image
    | args |
    args := OrderedCollection new.
    args add:'--useFile'; add:'./webServerSettings_8081.xml'.
    args add:self webServerSettingsSeperator.
    args add:' --useFile'; add:'./webServerSettings_8080.xml'.

    self new initialize startServersFromArguments:args.



ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 17 Oct 2019 10:35:22 GMT