commandbox.system.services

Class ServerService

lucee.Component
    extended by commandbox.system.services.ServerService

Copyright Since 2014 CommandBox by Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com I manage servers

Class Attributes:
  • singleton
  •  
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
  • author : Brad Wood, Luis Majano, Denny Valliant
  •  
    Property Summary
    type property default serializable required
    any CR


    • access = public
    • returntype = any
    • inject = CR@constants
    true false
    any JSONService


    • access = public
    • returntype = any
    • inject = JSONService
    true false
    any ansiFormater


    • access = public
    • returntype = any
    • inject = AnsiFormater
    true false
    any configService


    • access = public
    • returntype = any
    • inject = ConfigService
    true false
    any consoleLogger


    • access = public
    • returntype = any
    • inject = logbox:logger:console
    true false
    any customServerDirectory
          Where custom servers are stored.

    • access = public
    • returntype = any
    true false
    any interceptorService


    • access = public
    • returntype = any
    • inject = interceptorService
    true false
    any jarPath
          Where the Run War jar path is.

    • access = public
    • returntype = any
    true false
    any javaCommand
          Where the Java Command Executable is.

    • access = public
    • returntype = any
    true false
    any javaService


    • access = public
    • returntype = any
    • inject = provider:javaService
    true false
    any libDir
          Where the server libs are located.

    • access = public
    • returntype = any
    true false
    any packageService


    • access = public
    • returntype = any
    • inject = packageService
    true false
    any parser


    • access = public
    • returntype = any
    • inject = parser
    true false
    any printUtil


    • access = public
    • returntype = any
    • inject = print
    true false
    any rewritesDefaultConfig


    • access = public
    • returntype = any
    • inject = rewritesDefaultConfig@constants
    true false
    any serverConfig
          Where the server configuration file is.

    • access = public
    • returntype = any
    true false
    any serverEngineService


    • access = public
    • returntype = any
    • inject = serverEngineService
    true false
    any systemSettings


    • access = public
    • returntype = any
    • inject = SystemSettings
    true false
    any wirebox


    • access = public
    • returntype = any
    • inject = wirebox
    true false
    Constructor Summary
    init(any shell, any formatter, any fileSystem, any homeDir, any consoleLogger, any logger)
          Constructor.
    Method Summary
    array appendMenuItems([array trayOptions], [any relativePath], [array parentOptions])
         allows to iterate on a tray menu item recursively.
    any completeProperty(any directory, [any all='false'], [any asSet='false'])
         Dynamic completion for property name based on contents of server.
    any convertHeapToMB([any heapSize])
         Convert heap in format like 1G to 1024.
    any fixBinaryPath([any command], [any fullPath])
    any forget(struct serverInfo)
         Forget server from the configurations.
    string getAnsiFormater()
    string getCR()
    string getConfigService()
    string getConsoleLogger()
    string getCustomServerDirectory()
    any getCustomServerFolder(struct serverInfo)
         Get a custom server folder name according to our naming convention to avoid collisions with name.
    any getDefaultServerJSON()
    string getInterceptorService()
    string getJSONService()
    string getJarPath()
    string getJavaCommand()
    string getJavaService()
    string getLibDir()
    string getPackageService()
    string getParser()
    string getPrintUtil()
    any getRandomPort([any host='127.0.0.1'])
         Get a random port for the specified host.
    string getRewritesDefaultConfig()
    string getServerConfig()
    string getServerEngineService()
    struct getServerInfo(any webroot, any name)
         Get server info for webroot.
    struct getServerInfoByDiscovery(any directory='', any name='', [any serverConfigFile=''])
         Get a server information struct by name or directory.
    struct getServerInfoByName(any name)
         Get a server information struct by name, if not found it returns an empty struct.
    struct getServerInfoByServerConfigFile(any serverConfigFile)
         Get a server information struct by serverConfigFile if not found it returns an empty struct.
    struct getServerInfoByWebroot(any webroot)
         Get a server information struct by webrot, if not found it returns an empty struct.
    array getServerNames()
         Get all servers registered as an array of names.
    struct getServers()
         get servers struct from config file on disk.
    string getSystemSettings()
    string getWirebox()
    any initServers()
         Create initial server JSON.
    any isHeapLarger([any heapSize1], [any heapSize2])
         Detects if the first heap size is larger than the second.
    any isPortAvailable([any host='127.0.0.1'], any port)
         Find out if a given host/port is already bound.
    any isServerRunning(struct serverInfo)
         Logic to tell if a server is running.
    struct newServerInfoStruct()
         Returns a new server info structure.
    any normalizeWebroot(string webroot)
    any onDIComplete()
    any prepareMenuItem([any menuItem], [any relativePath])
         checks for the default image and default shell.
    struct readServerJSON(string path)
         Read a server.
    any resolveServerDetails(struct serverProps)
         Unified logic to resolve a server given an optional name, directory, and server.
    any saveServerJSON(string configFilePath, struct data)
         Save a server.
    any setAnsiFormater(any ansiFormater)
    any setCR(any CR)
    any setConfigService(any configService)
    any setConsoleLogger(any consoleLogger)
    any setCustomServerDirectory(any customServerDirectory)
    any setInterceptorService(any interceptorService)
    any setJSONService(any JSONService)
    any setJarPath(any jarPath)
    any setJavaCommand(any javaCommand)
    any setJavaService(any javaService)
    any setLibDir(any libDir)
    any setPackageService(any packageService)
    any setParser(any parser)
    any setPrintUtil(any printUtil)
    any setRewritesDefaultConfig(any rewritesDefaultConfig)
    any setServerConfig(any serverConfig)
    any setServerEngineService(any serverEngineService)
    any setServerInfo(struct serverInfo)
         persist server info.
    ServerService setServers(Struct servers)
         persist servers.
    any setSystemSettings(any systemSettings)
    any setWirebox(any wirebox)
    any start([Struct serverProps])
         Start a server instance.
    struct stop(struct serverInfo)
         Stop server.
     
    Methods inherited from class lucee.Component
    None

    Constructor Detail

    init

    public init(any shell, any formatter, any fileSystem, any homeDir, any consoleLogger, any logger)

    Constructor

    Parameters:
    shell
    formatter
    fileSystem
    homeDir
    consoleLogger
    logger

    Property Detail

    CR

    property any CR

    Attributes:
    access - public
    required - false
    returntype - any
    inject - CR@constants
    serializable - true

    JSONService

    property any JSONService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - JSONService
    serializable - true

    ansiFormater

    property any ansiFormater

    Attributes:
    access - public
    required - false
    returntype - any
    inject - AnsiFormater
    serializable - true

    configService

    property any configService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - ConfigService
    serializable - true

    consoleLogger

    property any consoleLogger

    Attributes:
    access - public
    required - false
    returntype - any
    inject - logbox:logger:console
    serializable - true

    customServerDirectory

    property any customServerDirectory

    Where custom servers are stored

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    interceptorService

    property any interceptorService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - interceptorService
    serializable - true

    jarPath

    property any jarPath

    Where the Run War jar path is

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    javaCommand

    property any javaCommand

    Where the Java Command Executable is

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    javaService

    property any javaService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - provider:javaService
    serializable - true

    libDir

    property any libDir

    Where the server libs are located

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    packageService

    property any packageService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - packageService
    serializable - true

    parser

    property any parser

    Attributes:
    access - public
    required - false
    returntype - any
    inject - parser
    serializable - true

    printUtil

    property any printUtil

    Attributes:
    access - public
    required - false
    returntype - any
    inject - print
    serializable - true

    rewritesDefaultConfig

    property any rewritesDefaultConfig

    Attributes:
    access - public
    required - false
    returntype - any
    inject - rewritesDefaultConfig@constants
    serializable - true

    serverConfig

    property any serverConfig

    Where the server configuration file is

    Attributes:
    access - public
    required - false
    returntype - any
    serializable - true

    serverEngineService

    property any serverEngineService

    Attributes:
    access - public
    required - false
    returntype - any
    inject - serverEngineService
    serializable - true

    systemSettings

    property any systemSettings

    Attributes:
    access - public
    required - false
    returntype - any
    inject - SystemSettings
    serializable - true

    wirebox

    property any wirebox

    Attributes:
    access - public
    required - false
    returntype - any
    inject - wirebox
    serializable - true

    Method Detail

    appendMenuItems

    public array appendMenuItems([array trayOptions], [any relativePath], [array parentOptions])

    allows to iterate on a tray menu item recursively and checks for the default image and default shell

    Parameters:
    trayOptions
    relativePath
    parentOptions

    completeProperty

    public any completeProperty(any directory, [any all='false'], [any asSet='false'])

    Dynamic completion for property name based on contents of server.json

    Parameters:
    directory - web root
    all - Pass false to ONLY suggest existing setting names. True will suggest all possible settings.
    asSet - Pass true to add = to the end of the options

    convertHeapToMB

    public any convertHeapToMB([any heapSize])

    Convert heap in format like 1G to 1024 Will always return MB, but without the "m"

    Parameters:
    heapSize

    fixBinaryPath

    public any fixBinaryPath([any command], [any fullPath])

    Parameters:
    command
    fullPath

    forget

    public any forget(struct serverInfo)

    Forget server from the configurations

    Parameters:
    serverInfo - struct of server info (ports, etc.)

    getAnsiFormater

    public string getAnsiFormater()


    getCR

    public string getCR()


    getConfigService

    public string getConfigService()


    getConsoleLogger

    public string getConsoleLogger()


    getCustomServerDirectory

    public string getCustomServerDirectory()


    getCustomServerFolder

    public any getCustomServerFolder(struct serverInfo)

    Get a custom server folder name according to our naming convention to avoid collisions with name

    Parameters:
    serverInfo - The server information

    getDefaultServerJSON

    public any getDefaultServerJSON()


    getInterceptorService

    public string getInterceptorService()


    getJSONService

    public string getJSONService()


    getJarPath

    public string getJarPath()


    getJavaCommand

    public string getJavaCommand()


    getJavaService

    public string getJavaService()


    getLibDir

    public string getLibDir()


    getPackageService

    public string getPackageService()


    getParser

    public string getParser()


    getPrintUtil

    public string getPrintUtil()


    getRandomPort

    public any getRandomPort([any host='127.0.0.1'])

    Get a random port for the specified host

    Parameters:
    host - host to get port on, defaults 127.0.0.1

    getRewritesDefaultConfig

    public string getRewritesDefaultConfig()


    getServerConfig

    public string getServerConfig()


    getServerEngineService

    public string getServerEngineService()


    getServerInfo

    public struct getServerInfo(any webroot, any name)

    Get server info for webroot

    Parameters:
    webroot - root directory for served content
    name

    getServerInfoByDiscovery

    public struct getServerInfoByDiscovery(any directory='', any name='', [any serverConfigFile=''])

    Get a server information struct by name or directory. Returns empty struct if not found.

    Parameters:
    directory - the directory to find
    name - The name to find
    serverConfigFile

    getServerInfoByName

    public struct getServerInfoByName(any name)

    Get a server information struct by name, if not found it returns an empty struct

    Parameters:
    name - The name to find

    getServerInfoByServerConfigFile

    public struct getServerInfoByServerConfigFile(any serverConfigFile)

    Get a server information struct by serverConfigFile if not found it returns an empty struct

    Parameters:
    serverConfigFile

    getServerInfoByWebroot

    public struct getServerInfoByWebroot(any webroot)

    Get a server information struct by webrot, if not found it returns an empty struct

    Parameters:
    webroot - The webroot to find

    getServerNames

    public array getServerNames()

    Get all servers registered as an array of names


    getServers

    public struct getServers()

    get servers struct from config file on disk


    getSystemSettings

    public string getSystemSettings()


    getWirebox

    public string getWirebox()


    initServers

    public any initServers()

    Create initial server JSON


    isHeapLarger

    public any isHeapLarger([any heapSize1], [any heapSize2])

    Detects if the first heap size is larger than the second

    Parameters:
    heapSize1 - Specified as 1024m, 2G, or 512k
    heapSize2 - Specified as 1024m, 2G, or 512k

    isPortAvailable

    public any isPortAvailable([any host='127.0.0.1'], any port)

    Find out if a given host/port is already bound

    Parameters:
    host - host to test port on, defaults 127.0.0.1
    port

    isServerRunning

    public any isServerRunning(struct serverInfo)

    Logic to tell if a server is running

    Parameters:
    serverInfo - Struct of server information

    newServerInfoStruct

    public struct newServerInfoStruct()

    Returns a new server info structure


    normalizeWebroot

    public any normalizeWebroot(string webroot)

    Parameters:
    webroot

    onDIComplete

    public any onDIComplete()


    prepareMenuItem

    public any prepareMenuItem([any menuItem], [any relativePath])

    checks for the default image and default shell

    Parameters:
    menuItem
    relativePath

    readServerJSON

    public struct readServerJSON(string path)

    Read a server.json file. If it doesn't exist, returns an empty struct This only returns properties specifically set in the file.

    Parameters:
    path

    resolveServerDetails

    public any resolveServerDetails(struct serverProps)

    Unified logic to resolve a server given an optional name, directory, and server.json path. Returns resolved name, webroot, serverConfigFile, serverInfo from the last start and serverJSON Use this for all 'server' commands that let a user specify the server they want by convention (CWD), name, directory, or server.json path. - defaultName - defaultwebroot - defaultServerConfigFile - serverJSON - serverInfo - serverIsNew

    Parameters:
    serverProps - A struct that can contains name, directory, and/or serverConfigFile

    saveServerJSON

    public any saveServerJSON(string configFilePath, struct data)

    Save a server.json file.

    Parameters:
    configFilePath
    data

    setAnsiFormater

    public any setAnsiFormater(any ansiFormater)

    Parameters:
    ansiFormater

    setCR

    public any setCR(any CR)

    Parameters:
    CR

    setConfigService

    public any setConfigService(any configService)

    Parameters:
    configService

    setConsoleLogger

    public any setConsoleLogger(any consoleLogger)

    Parameters:
    consoleLogger

    setCustomServerDirectory

    public any setCustomServerDirectory(any customServerDirectory)

    Parameters:
    customServerDirectory

    setInterceptorService

    public any setInterceptorService(any interceptorService)

    Parameters:
    interceptorService

    setJSONService

    public any setJSONService(any JSONService)

    Parameters:
    JSONService

    setJarPath

    public any setJarPath(any jarPath)

    Parameters:
    jarPath

    setJavaCommand

    public any setJavaCommand(any javaCommand)

    Parameters:
    javaCommand

    setJavaService

    public any setJavaService(any javaService)

    Parameters:
    javaService

    setLibDir

    public any setLibDir(any libDir)

    Parameters:
    libDir

    setPackageService

    public any setPackageService(any packageService)

    Parameters:
    packageService

    setParser

    public any setParser(any parser)

    Parameters:
    parser

    setPrintUtil

    public any setPrintUtil(any printUtil)

    Parameters:
    printUtil

    setRewritesDefaultConfig

    public any setRewritesDefaultConfig(any rewritesDefaultConfig)

    Parameters:
    rewritesDefaultConfig

    setServerConfig

    public any setServerConfig(any serverConfig)

    Parameters:
    serverConfig

    setServerEngineService

    public any setServerEngineService(any serverEngineService)

    Parameters:
    serverEngineService

    setServerInfo

    public any setServerInfo(struct serverInfo)

    persist server info

    Parameters:
    serverInfo - struct of server info (ports, etc.)

    setServers

    public ServerService setServers(Struct servers)

    persist servers

    Parameters:
    servers - struct of serverInfos

    setSystemSettings

    public any setSystemSettings(any systemSettings)

    Parameters:
    systemSettings

    setWirebox

    public any setWirebox(any wirebox)

    Parameters:
    wirebox

    start

    public any start([Struct serverProps])

    Start a server instance

    Parameters:
    serverProps - A struct of settings to influence how to start the server. Params not provided by the user are null.

    stop

    public struct stop(struct serverInfo)

    Stop server

    Parameters:
    serverInfo - The server information struct: [ webroot, name, port, stopSocket, logDir, status, statusInfo ]