implementation module iTasks.Framework.Engine import StdMisc, StdArray, StdList, StdOrdList, StdTuple, StdChar, StdFile, StdBool from StdFunc import o, seqList, ::St import Data.Map, Data.Error, Data.Func, Data.Tuple, Internet.HTTP, Text, Text.Encodings.MIME, Text.Encodings.UrlEncoding import System.Time, System.CommandLine, System.Environment, System.OSError, System.File, System.FilePath, System.Directory import iTasks.Framework.Util, iTasks.Framework.HtmlUtil import iTasks.Framework.IWorld, iTasks.Framework.WebService CLEAN_HOME_VAR :== "CLEAN_HOME" import StdFile, StdInt, StdList, StdChar, StdBool, StdString, StdFunc import tcp import Internet.HTTP, System.Time, System.CommandLine, Data.Func import iTasks.Framework.Engine, iTasks.Framework.IWorld, iTasks.Framework.TaskEval, iTasks.Framework.TaskStore import iTasks.Framework.Util import iTasks.Framework.TaskServer from Data.Set import :: Set, newSet from Sapl.Linker.LazyLinker import generateLoaderState, :: LoaderStateExt from Sapl.Linker.SaplLinkerShared import :: SkipSet from Sapl.Target.JS.Flavour import :: Flavour, toFlavour startEngine :: a !*World -> *World | Publishable a startEngine publishable world # (opts,world) = getCommandLine world # (app,world) = determineAppName world # (mbSDKPath,world) = determineSDKPath SEARCH_PATHS world // Show server name # world = show (infoline app) world //Check options # port = fromMaybe DEFAULT_PORT (intOpt "-port" opts) # keepalive = fromMaybe DEFAULT_KEEPALIVE_TIME (intOpt "-keepalive" opts) # help = boolOpt "-help" opts # sdkOpt = stringOpt "-sdk" opts //If -help option is given show help and stop | help = show instructions world //Check sdkpath # mbSDKPath = maybe mbSDKPath Just sdkOpt //Commandline SDK option overrides found paths | isNothing mbSDKPath = show sdkpatherror world //Normal execution # world = show (running port) world # iworld = initIWorld (fromJust mbSDKPath) world // mark all instance as outdated initially # (maxNo,iworld) = maxInstanceNo iworld # iworld = addOutdatedInstances [(instanceNo, Nothing) \\ instanceNo <- [1..maxNo]] iworld # iworld = startHTTPServer port keepalive (engine publishable) timeout background iworld = finalizeIWorld iworld where infoline :: !String -> [String] infoline app = ["*** " +++ app +++ " HTTP server ***",""] instructions :: [String] instructions = ["Available commandline options:" ," -help : Show this message and exit" ," -sdk : Use as location of the iTasks SDK" ," -port : Set port number (default " +++ toString DEFAULT_PORT +++ ")" ," -keepalive