-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Web application deployment manager, focusing on Haskell web frameworks. It mitigates downtime.
--
-- Deployment system for web applications, originally intended for
-- hosting Yesod applications. It binds to the main port (usually port
-- 80) and reverse proxies requests to your application based on virtual
-- hostnames. It provides SSL support if requested. It automatically
-- launches applications, monitors processes, and relaunches any
-- processes which die. It also provides graceful redeployment support,
-- which mitigates downtime.
@package keter
@version 2.1.6
module Keter.Conduit.Process.Unix
-- | Represents the child process which handles process cleanup.
--
-- Since 0.2.1
data ProcessTracker
-- | Fork off the child cleanup process.
--
-- This will ideally only be run once for your entire application.
--
-- Since 0.2.1
initProcessTracker :: IO ProcessTracker
-- | Abstract type containing information on a process which will be
-- restarted.
data MonitoredProcess
-- | Run the given command, restarting if the process dies.
monitorProcess :: (MonadUnliftIO m, MonadLogger m) => ProcessTracker -> Maybe ByteString -> ByteString -> ByteString -> [ByteString] -> [(ByteString, ByteString)] -> (ByteString -> IO ()) -> (ExitCode -> IO Bool) -> m MonitoredProcess
-- | Terminate the process and prevent it from being restarted.
terminateMonitoredProcess :: MonitoredProcess -> IO ()
printStatus :: MonitoredProcess -> IO Text
instance GHC.Show.Show Keter.Conduit.Process.Unix.ProcessTrackerException
instance GHC.Exception.Type.Exception Keter.Conduit.Process.Unix.ProcessTrackerException
module Keter.Config.Middleware
data MiddlewareConfig
AcceptOverride :: MiddlewareConfig
Autohead :: MiddlewareConfig
Jsonp :: MiddlewareConfig
MethodOverride :: MiddlewareConfig
MethodOverridePost :: MiddlewareConfig
AddHeaders :: ![(ByteString, ByteString)] -> MiddlewareConfig
-- | Realm [(username,password)]
BasicAuth :: !String -> ![(ByteString, ByteString)] -> MiddlewareConfig
-- | Status Message
Local :: !Int -> !ByteString -> MiddlewareConfig
processMiddleware :: [MiddlewareConfig] -> Middleware
toMiddleware :: MiddlewareConfig -> Middleware
composeMiddleware :: [Middleware] -> Middleware
instance GHC.Generics.Generic Keter.Config.Middleware.MiddlewareConfig
instance GHC.Show.Show Keter.Config.Middleware.MiddlewareConfig
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Config.Middleware.MiddlewareConfig
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Config.Middleware.MiddlewareConfig
module Keter.LabelMap
-- | A data structure for storing a hierarchical set of domain labels from
-- TLD down, supporting wildcards.
--
-- Data structure is mutually recursive with LabelEntry, and each
-- level of the tree supports a static assignment for a hostname such as:
--
--
-- example.com
--
--
-- Or a wildcard assignment for a hostname such as:
--
--
-- *.example.com
--
--
-- Or a wildcard assignment with a set of teptions, for example:
--
--
-- *.example.com
-- admin.example.com
--
--
-- And lastly, empty labels are supported so that, of course, an
-- assignment for example.com does not necessarily have any subdomains
-- available. As an example suppose we have the following assigned
-- domains:
--
--
-- example.com
-- foo.example.com
-- *.bar.example.com
-- *.qux.example.com
-- baz.qux.example.com
--
--
-- This will resolve to the following value, with some loose pseudocode
-- notation.
--
--
-- Static (map)
-- 'com' -> Unassigned Static (map)
-- 'example' -> Assigned a (map)
-- 'foo' -> Assigned a EmptyLabelMap
-- 'bar' -> Unassigned (Wildcard (Assigned a EmptyLabelMap)
-- 'qux' -> Unassigned (WildcardExcept (Assigned a (map)))
-- 'baz' -> Assigned a EmptyLabelMap
--
--
-- Note that the hostname "bar.example.com" is unassigned, only the
-- wildcard was set.
data LabelMap a
insert :: ByteString -> a -> LabelMap a -> LabelMap a
delete :: ByteString -> LabelMap a -> LabelMap a
lookup :: ByteString -> LabelMap a -> Maybe a
labelAssigned :: ByteString -> LabelMap a -> Bool
empty :: LabelMap a
instance GHC.Classes.Eq a => GHC.Classes.Eq (Keter.LabelMap.LabelMap a)
instance GHC.Show.Show (Keter.LabelMap.LabelMap a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Keter.LabelMap.LabelEntry a)
instance GHC.Show.Show (Keter.LabelMap.LabelEntry a)
-- | Handles allocation of temporary directories and unpacking of bundles
-- into them. Sets owner and group of all created files and directories
-- as necessary.
module Keter.TempTarball
data TempFolder
setup :: FilePath -> IO TempFolder
unpackTempTar :: Maybe (UserID, GroupID) -> TempFolder -> FilePath -> Text -> (FilePath -> IO a) -> IO a
-- | Utilities for dealing with YAML config files which contain relative
-- file paths.
module Keter.Yaml.FilePath
-- | Parse a config file, using the ParseYamlFile typeclass.
decodeFileRelative :: ParseYamlFile a => FilePath -> IO (Either ParseException a)
-- | A replacement for the .: operator which will both parse a
-- file path and apply the relative file logic.
lookupBase :: ParseYamlFile a => BaseDir -> Object -> Text -> Parser a
-- | A replacement for the .:? operator which will both parse a
-- file path and apply the relative file logic.
lookupBaseMaybe :: ParseYamlFile a => BaseDir -> Object -> Text -> Parser (Maybe a)
-- | The directory from which we're reading the config file.
data BaseDir
-- | A replacement for the standard FromJSON typeclass which can
-- handle relative filepaths.
class ParseYamlFile a
parseYamlFile :: ParseYamlFile a => BaseDir -> Value -> Parser a
data NonEmptyVector a
NonEmptyVector :: !a -> !Vector a -> NonEmptyVector a
instance Keter.Yaml.FilePath.ParseYamlFile a => Keter.Yaml.FilePath.ParseYamlFile (Keter.Yaml.FilePath.NonEmptyVector a)
instance Keter.Yaml.FilePath.ParseYamlFile GHC.IO.FilePath
instance (Keter.Yaml.FilePath.ParseYamlFile a, GHC.Classes.Ord a) => Keter.Yaml.FilePath.ParseYamlFile (Data.Set.Internal.Set a)
instance Keter.Yaml.FilePath.ParseYamlFile a => Keter.Yaml.FilePath.ParseYamlFile (Data.Vector.Vector a)
-- | Provides logging, versioning and some type aliases
module Keter.Common
-- | Name of the application. Should just be the basename of the
-- application file.
type Appname = Text
data Plugin
Plugin :: (Appname -> Object -> IO [(Text, Text)]) -> Plugin
[pluginGetEnv] :: Plugin -> Appname -> Object -> IO [(Text, Text)]
type Plugins = [Plugin]
-- | Used for versioning data types.
class ToCurrent a where {
type Previous a;
}
toCurrent :: ToCurrent a => Previous a -> a
-- | A port for an individual app to listen on.
type Port = Int
-- | A virtual host we want to serve content from.
type Host = CI Text
type HostBS = CI ByteString
getAppname :: FilePath -> Text
data KeterException
CannotParsePostgres :: FilePath -> KeterException
ExitCodeFailure :: FilePath -> ExitCode -> KeterException
NoPortsAvailable :: KeterException
InvalidConfigFile :: ParseException -> KeterException
InvalidKeterConfigFile :: !FilePath -> !ParseException -> KeterException
CannotReserveHosts :: !AppId -> !Map Host AppId -> KeterException
FileNotExecutable :: !FilePath -> KeterException
ExecutableNotFound :: !FilePath -> KeterException
EnsureAliveShouldBeBiggerThenZero :: !Int -> KeterException
[keterExceptionGot] :: KeterException -> !Int
data AppId
AIBuiltin :: AppId
AINamed :: !Appname -> AppId
data SSLConfig
SSLFalse :: SSLConfig
SSLTrue :: SSLConfig
SSL :: !FilePath -> !Vector FilePath -> !FilePath -> SSLConfig
instance GHC.Classes.Ord Keter.Common.AppId
instance GHC.Classes.Eq Keter.Common.AppId
instance GHC.Show.Show Keter.Common.KeterException
instance GHC.Classes.Ord Keter.Common.SSLConfig
instance GHC.Classes.Eq Keter.Common.SSLConfig
instance GHC.Show.Show Keter.Common.SSLConfig
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Common.SSLConfig
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Common.SSLConfig
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Common.SSLConfig
instance GHC.Exception.Type.Exception Keter.Common.KeterException
instance GHC.Show.Show Keter.Common.AppId
instance Keter.Common.ToCurrent a => Keter.Common.ToCurrent (GHC.Maybe.Maybe a)
module Keter.Rewrite
data ReverseProxyConfig
ReverseProxyConfig :: Text -> Int -> Bool -> Text -> !SSLConfig -> Maybe Int -> Set RewriteRule -> Set RewriteRule -> ReverseProxyConfig
[reversedHost] :: ReverseProxyConfig -> Text
[reversedPort] :: ReverseProxyConfig -> Int
[reversedUseSSL] :: ReverseProxyConfig -> Bool
[reversingHost] :: ReverseProxyConfig -> Text
[reversingUseSSL] :: ReverseProxyConfig -> !SSLConfig
[reverseTimeout] :: ReverseProxyConfig -> Maybe Int
[rewriteResponseRules] :: ReverseProxyConfig -> Set RewriteRule
[rewriteRequestRules] :: ReverseProxyConfig -> Set RewriteRule
data RewriteRule
RewriteRule :: Text -> Text -> Text -> RewriteRule
[ruleHeader] :: RewriteRule -> Text
[ruleRegex] :: RewriteRule -> Text
[ruleReplacement] :: RewriteRule -> Text
data RPEntry
RPEntry :: ReverseProxyConfig -> Manager -> RPEntry
[config] :: RPEntry -> ReverseProxyConfig
[httpManager] :: RPEntry -> Manager
simpleReverseProxy :: Manager -> ReverseProxyConfig -> Application
instance GHC.Show.Show Keter.Rewrite.RewriteRule
instance GHC.Classes.Ord Keter.Rewrite.RewriteRule
instance GHC.Classes.Eq Keter.Rewrite.RewriteRule
instance GHC.Show.Show Keter.Rewrite.ReverseProxyConfig
instance GHC.Classes.Ord Keter.Rewrite.ReverseProxyConfig
instance GHC.Classes.Eq Keter.Rewrite.ReverseProxyConfig
instance GHC.Show.Show Keter.Rewrite.RPEntry
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Rewrite.ReverseProxyConfig
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Rewrite.ReverseProxyConfig
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Rewrite.RewriteRule
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Rewrite.RewriteRule
module Keter.Plugin.Postgres
data Settings
-- | How to create the given user/database. Default: uses the psql
-- command line tool and sudo -u postgres.
setupDBInfo :: Settings -> DBInfo -> IO ()
defaultSettings :: Settings
-- | Load a set of existing connections from a config file. If the file
-- does not exist, it will be created. Any newly created databases will
-- automatically be saved to this file.
load :: Settings -> FilePath -> IO Plugin
instance GHC.Show.Show Keter.Plugin.Postgres.DBServerInfo
instance GHC.Show.Show Keter.Plugin.Postgres.DBInfo
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Plugin.Postgres.DBInfo
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Plugin.Postgres.DBInfo
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Plugin.Postgres.DBServerInfo
module Keter.Context
-- | The top-level keter context monad, carrying around the main logger and
-- some locally relevant configuration structure.
--
-- See this blog post for an explanation of the design philosophy:
-- https://www.fpcomplete.com/blog/2017/06/readert-design-pattern/
--
-- TODO: generalize as contexts instead of configs? Since
-- not every state being passed around can be intuitively thought of as a
-- config per se. Ex. AppManager
newtype KeterM cfg a
KeterM :: LoggingT (ReaderT cfg IO) a -> KeterM cfg a
[runKeterM] :: KeterM cfg a -> LoggingT (ReaderT cfg IO) a
withMappedConfig :: (cfg -> cfg') -> KeterM cfg' a -> KeterM cfg a
instance Control.Monad.Reader.Class.MonadReader cfg (Keter.Context.KeterM cfg)
instance Control.Monad.Logger.MonadLoggerIO (Keter.Context.KeterM cfg)
instance Control.Monad.Logger.MonadLogger (Keter.Context.KeterM cfg)
instance Control.Monad.IO.Class.MonadIO (Keter.Context.KeterM cfg)
instance Control.Monad.IO.Unlift.MonadUnliftIO (Keter.Context.KeterM cfg)
instance GHC.Base.Monad (Keter.Context.KeterM cfg)
instance GHC.Base.Applicative (Keter.Context.KeterM cfg)
instance GHC.Base.Functor (Keter.Context.KeterM cfg)
-- | Legacy types from Keter version 0.4. Retained to keep backwards
-- compatibility in config file format.
module Keter.Config.V04
data AppConfig
AppConfig :: FilePath -> [Text] -> Text -> Bool -> Set Text -> Object -> AppConfig
[configExec] :: AppConfig -> FilePath
[configArgs] :: AppConfig -> [Text]
[configHost] :: AppConfig -> Text
[configSsl] :: AppConfig -> Bool
[configExtraHosts] :: AppConfig -> Set Text
[configRaw] :: AppConfig -> Object
data BundleConfig
BundleConfig :: Maybe AppConfig -> Set StaticHost -> Set Redirect -> BundleConfig
[bconfigApp] :: BundleConfig -> Maybe AppConfig
[bconfigStaticHosts] :: BundleConfig -> Set StaticHost
[bconfigRedirects] :: BundleConfig -> Set Redirect
data StaticHost
StaticHost :: Text -> FilePath -> StaticHost
[shHost] :: StaticHost -> Text
[shRoot] :: StaticHost -> FilePath
data Redirect
Redirect :: Text -> Text -> Redirect
[redFrom] :: Redirect -> Text
[redTo] :: Redirect -> Text
data KeterConfig
KeterConfig :: FilePath -> PortSettings -> HostPreference -> Port -> Maybe TLSConfig -> Maybe Text -> Set ReverseProxyConfig -> Bool -> Int -> KeterConfig
[kconfigDir] :: KeterConfig -> FilePath
[kconfigPortMan] :: KeterConfig -> PortSettings
[kconfigHost] :: KeterConfig -> HostPreference
[kconfigPort] :: KeterConfig -> Port
[kconfigSsl] :: KeterConfig -> Maybe TLSConfig
[kconfigSetuid] :: KeterConfig -> Maybe Text
[kconfigReverseProxy] :: KeterConfig -> Set ReverseProxyConfig
[kconfigIpFromHeader] :: KeterConfig -> Bool
-- | Maximum request time in milliseconds per connection.
[kconfigConnectionTimeBound] :: KeterConfig -> Int
defaultKeterConfig :: KeterConfig
-- | Default connection time bound in milliseconds.
fiveMinutes :: Int
data TLSConfig
TLSConfig :: !Settings -> !FilePath -> !FilePath -> Maybe Config -> TLSConfig
-- | Controls execution of the nginx thread. Follows the settings type
-- pattern. See: http://www.yesodweb.com/book/settings-types.
data PortSettings
PortSettings :: [Port] -> PortSettings
-- | Which ports to assign to apps. Defaults to unassigned ranges from IANA
[portRange] :: PortSettings -> [Port]
defaultPortSettings :: PortSettings
instance GHC.Classes.Ord Keter.Config.V04.StaticHost
instance GHC.Classes.Eq Keter.Config.V04.StaticHost
instance GHC.Classes.Ord Keter.Config.V04.Redirect
instance GHC.Classes.Eq Keter.Config.V04.Redirect
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V04.KeterConfig
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Config.V04.PortSettings
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V04.TLSConfig
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V04.BundleConfig
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Config.V04.Redirect
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V04.StaticHost
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V04.AppConfig
module Keter.Config.V10
data BundleConfig
BundleConfig :: !Vector (Stanza ()) -> !Object -> BundleConfig
[bconfigStanzas] :: BundleConfig -> !Vector (Stanza ())
-- | settings used for plugins
[bconfigPlugins] :: BundleConfig -> !Object
data ListeningPort
LPSecure :: !HostPreference -> !Port -> !FilePath -> !Vector FilePath -> !FilePath -> !Bool -> ListeningPort
LPInsecure :: !HostPreference -> !Port -> ListeningPort
data KeterConfig
KeterConfig :: FilePath -> PortSettings -> !NonEmptyVector ListeningPort -> Maybe Text -> !Vector (Stanza ()) -> Bool -> !Int -> !Int -> !Map Text Text -> !Int -> !Maybe Port -> !Maybe FilePath -> !Maybe FilePath -> !Maybe FilePath -> !Bool -> !Maybe Text -> KeterConfig
[kconfigDir] :: KeterConfig -> FilePath
[kconfigPortPool] :: KeterConfig -> PortSettings
[kconfigListeners] :: KeterConfig -> !NonEmptyVector ListeningPort
[kconfigSetuid] :: KeterConfig -> Maybe Text
[kconfigBuiltinStanzas] :: KeterConfig -> !Vector (Stanza ())
[kconfigIpFromHeader] :: KeterConfig -> Bool
-- | External HTTP port when generating APPROOTs.
[kconfigExternalHttpPort] :: KeterConfig -> !Int
-- | External HTTPS port when generating APPROOTs.
[kconfigExternalHttpsPort] :: KeterConfig -> !Int
-- | Environment variables to be passed to all apps.
[kconfigEnvironment] :: KeterConfig -> !Map Text Text
-- | Maximum request time in milliseconds per connection.
[kconfigConnectionTimeBound] :: KeterConfig -> !Int
-- | Port for the cli to listen on
[kconfigCliPort] :: KeterConfig -> !Maybe Port
[kconfigUnknownHostResponse] :: KeterConfig -> !Maybe FilePath
[kconfigMissingHostResponse] :: KeterConfig -> !Maybe FilePath
[kconfigProxyException] :: KeterConfig -> !Maybe FilePath
[kconfigRotateLogs] :: KeterConfig -> !Bool
[kconfigHealthcheckPath] :: KeterConfig -> !Maybe Text
defaultKeterConfig :: KeterConfig
-- | Whether we should force redirect to HTTPS routes.
type RequiresSecure = Bool
data Stanza port
Stanza :: StanzaRaw port -> RequiresSecure -> Stanza port
data StanzaRaw port
StanzaStaticFiles :: !StaticFilesConfig -> StanzaRaw port
StanzaRedirect :: !RedirectConfig -> StanzaRaw port
StanzaWebApp :: !WebAppConfig port -> StanzaRaw port
StanzaReverseProxy :: !ReverseProxyConfig -> ![MiddlewareConfig] -> !Maybe Int -> StanzaRaw port
StanzaBackground :: !BackgroundConfig -> StanzaRaw port
-- | An action to be performed for a requested hostname.
--
-- This datatype is very similar to Stanza, but is necessarily separate
-- since:
--
--
-- - Webapps will be assigned ports.
-- - Not all stanzas have an associated proxy action.
--
data ProxyActionRaw
PAPort :: Port -> !Maybe Int -> ProxyActionRaw
PAStatic :: StaticFilesConfig -> ProxyActionRaw
PARedirect :: RedirectConfig -> ProxyActionRaw
PAReverseProxy :: ReverseProxyConfig -> ![MiddlewareConfig] -> !Maybe Int -> ProxyActionRaw
type ProxyAction = (ProxyActionRaw, RequiresSecure)
addRequiresSecure :: ToJSON a => Bool -> a -> Value
addStanzaType :: ToJSON a => Value -> a -> Value
data StaticFilesConfig
StaticFilesConfig :: !FilePath -> !Set Host -> !Bool -> ![MiddlewareConfig] -> !Maybe Int -> !SSLConfig -> StaticFilesConfig
[sfconfigRoot] :: StaticFilesConfig -> !FilePath
[sfconfigHosts] :: StaticFilesConfig -> !Set Host
[sfconfigListings] :: StaticFilesConfig -> !Bool
[sfconfigMiddleware] :: StaticFilesConfig -> ![MiddlewareConfig]
[sfconfigTimeout] :: StaticFilesConfig -> !Maybe Int
[sfconfigSsl] :: StaticFilesConfig -> !SSLConfig
data RedirectConfig
RedirectConfig :: !Set Host -> !Int -> !Vector RedirectAction -> !SSLConfig -> RedirectConfig
[redirconfigHosts] :: RedirectConfig -> !Set Host
[redirconfigStatus] :: RedirectConfig -> !Int
[redirconfigActions] :: RedirectConfig -> !Vector RedirectAction
[redirconfigSsl] :: RedirectConfig -> !SSLConfig
data RedirectAction
RedirectAction :: !SourcePath -> !RedirectDest -> RedirectAction
data SourcePath
SPAny :: SourcePath
SPSpecific :: !Text -> SourcePath
data RedirectDest
RDUrl :: !Text -> RedirectDest
RDPrefix :: !IsSecure -> !Host -> !Maybe Port -> RedirectDest
type IsSecure = Bool
data WebAppConfig port
WebAppConfig :: !FilePath -> !Vector Text -> !Map Text Text -> !Host -> !Set Host -> !SSLConfig -> !port -> !Set Text -> !Maybe Int -> !Maybe Int -> WebAppConfig port
[waconfigExec] :: WebAppConfig port -> !FilePath
[waconfigArgs] :: WebAppConfig port -> !Vector Text
[waconfigEnvironment] :: WebAppConfig port -> !Map Text Text
-- | primary host, used for approot
[waconfigApprootHost] :: WebAppConfig port -> !Host
-- | all hosts, not including the approot host
[waconfigHosts] :: WebAppConfig port -> !Set Host
[waconfigSsl] :: WebAppConfig port -> !SSLConfig
[waconfigPort] :: WebAppConfig port -> !port
[waconfigForwardEnv] :: WebAppConfig port -> !Set Text
-- | how long are connections supposed to last
[waconfigTimeout] :: WebAppConfig port -> !Maybe Int
-- | how long in microseconds the app gets before we expect it to bind to a
-- port (default 90 seconds)
[waconfigEnsureAliveTimeout] :: WebAppConfig port -> !Maybe Int
data AppInput
AIBundle :: !FilePath -> !EpochTime -> AppInput
AIData :: !BundleConfig -> AppInput
data BackgroundConfig
BackgroundConfig :: !FilePath -> !Vector Text -> !Map Text Text -> !RestartCount -> !Word -> !Set Text -> BackgroundConfig
[bgconfigExec] :: BackgroundConfig -> !FilePath
[bgconfigArgs] :: BackgroundConfig -> !Vector Text
[bgconfigEnvironment] :: BackgroundConfig -> !Map Text Text
[bgconfigRestartCount] :: BackgroundConfig -> !RestartCount
[bgconfigRestartDelaySeconds] :: BackgroundConfig -> !Word
[bgconfigForwardEnv] :: BackgroundConfig -> !Set Text
data RestartCount
UnlimitedRestarts :: RestartCount
LimitedRestarts :: !Word -> RestartCount
instance GHC.Show.Show Keter.Config.V10.StaticFilesConfig
instance GHC.Show.Show Keter.Config.V10.SourcePath
instance GHC.Show.Show Keter.Config.V10.RedirectDest
instance GHC.Show.Show Keter.Config.V10.RedirectAction
instance GHC.Show.Show Keter.Config.V10.RedirectConfig
instance GHC.Show.Show Keter.Config.V10.ProxyActionRaw
instance GHC.Show.Show port => GHC.Show.Show (Keter.Config.V10.WebAppConfig port)
instance GHC.Show.Show Keter.Config.V10.RestartCount
instance GHC.Show.Show Keter.Config.V10.BackgroundConfig
instance GHC.Show.Show port => GHC.Show.Show (Keter.Config.V10.StanzaRaw port)
instance GHC.Show.Show port => GHC.Show.Show (Keter.Config.V10.Stanza port)
instance GHC.Show.Show Keter.Config.V10.BundleConfig
instance GHC.Show.Show Keter.Config.V10.AppInput
instance Keter.Common.ToCurrent Keter.Config.V10.BundleConfig
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V10.BundleConfig
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Config.V10.BundleConfig
instance Keter.Common.ToCurrent Keter.Config.V10.KeterConfig
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V10.KeterConfig
instance Keter.Yaml.FilePath.ParseYamlFile (Keter.Config.V10.Stanza ())
instance Data.Aeson.Types.ToJSON.ToJSON (Keter.Config.V10.Stanza ())
instance Data.Aeson.Types.ToJSON.ToJSON (Keter.Config.V10.StanzaRaw ())
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V10.BackgroundConfig
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Config.V10.BackgroundConfig
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Config.V10.RestartCount
instance Keter.Common.ToCurrent (Keter.Config.V10.WebAppConfig ())
instance Keter.Yaml.FilePath.ParseYamlFile (Keter.Config.V10.WebAppConfig ())
instance Data.Aeson.Types.ToJSON.ToJSON (Keter.Config.V10.WebAppConfig ())
instance Keter.Common.ToCurrent Keter.Config.V10.RedirectConfig
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V10.RedirectConfig
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Config.V10.RedirectConfig
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Config.V10.RedirectAction
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Config.V10.RedirectAction
instance Data.Aeson.Types.FromJSON.FromJSON Keter.Config.V10.RedirectDest
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Config.V10.RedirectDest
instance Keter.Common.ToCurrent Keter.Config.V10.StaticFilesConfig
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V10.StaticFilesConfig
instance Data.Aeson.Types.ToJSON.ToJSON Keter.Config.V10.StaticFilesConfig
instance Keter.Yaml.FilePath.ParseYamlFile Keter.Config.V10.ListeningPort
module Keter.Logger
-- | Record wrapper over a fast logger (log,close) function tuple, just to
-- make it less unwieldy and obscure. The LogType is also
-- tracked, in case formatting depends on it.
data Logger
Logger :: (forall a. ToLogStr a => a -> IO ()) -> IO () -> LogType -> Logger
[loggerLog] :: Logger -> forall a. ToLogStr a => a -> IO ()
[loggerClose] :: Logger -> IO ()
[loggerType] :: Logger -> LogType
-- | Create a logger based on a KeterConfig. If log rotation is
-- enabled in the config, this will return a rotating file logger; and a
-- stderr logger otherwise.
createLoggerViaConfig :: KeterConfig -> String -> IO Logger
defaultRotationSpec :: FilePath -> FileLogSpec
-- | The default total file size before for a log file before it needs to
-- be rotated
defaultMaxTotal :: Integer
-- | The default log message buffer size
defaultBufferSize :: Int
-- | This does a merger of V04 and V10 Effectivelly this provides the
-- latest config.
module Keter.Config
-- | Controls execution of the nginx thread. Follows the settings type
-- pattern. See: http://www.yesodweb.com/book/settings-types.
data PortSettings
PortSettings :: [Port] -> PortSettings
-- | Which ports to assign to apps. Defaults to unassigned ranges from IANA
[portRange] :: PortSettings -> [Port]
data TLSConfig
TLSConfig :: !Settings -> !FilePath -> !FilePath -> Maybe Config -> TLSConfig
data BundleConfig
BundleConfig :: !Vector (Stanza ()) -> !Object -> BundleConfig
[bconfigStanzas] :: BundleConfig -> !Vector (Stanza ())
-- | settings used for plugins
[bconfigPlugins] :: BundleConfig -> !Object
data WebAppConfig port
WebAppConfig :: !FilePath -> !Vector Text -> !Map Text Text -> !Host -> !Set Host -> !SSLConfig -> !port -> !Set Text -> !Maybe Int -> !Maybe Int -> WebAppConfig port
[waconfigExec] :: WebAppConfig port -> !FilePath
[waconfigArgs] :: WebAppConfig port -> !Vector Text
[waconfigEnvironment] :: WebAppConfig port -> !Map Text Text
-- | primary host, used for approot
[waconfigApprootHost] :: WebAppConfig port -> !Host
-- | all hosts, not including the approot host
[waconfigHosts] :: WebAppConfig port -> !Set Host
[waconfigSsl] :: WebAppConfig port -> !SSLConfig
[waconfigPort] :: WebAppConfig port -> !port
[waconfigForwardEnv] :: WebAppConfig port -> !Set Text
-- | how long are connections supposed to last
[waconfigTimeout] :: WebAppConfig port -> !Maybe Int
-- | how long in microseconds the app gets before we expect it to bind to a
-- port (default 90 seconds)
[waconfigEnsureAliveTimeout] :: WebAppConfig port -> !Maybe Int
data RedirectConfig
RedirectConfig :: !Set Host -> !Int -> !Vector RedirectAction -> !SSLConfig -> RedirectConfig
[redirconfigHosts] :: RedirectConfig -> !Set Host
[redirconfigStatus] :: RedirectConfig -> !Int
[redirconfigActions] :: RedirectConfig -> !Vector RedirectAction
[redirconfigSsl] :: RedirectConfig -> !SSLConfig
data StaticFilesConfig
StaticFilesConfig :: !FilePath -> !Set Host -> !Bool -> ![MiddlewareConfig] -> !Maybe Int -> !SSLConfig -> StaticFilesConfig
[sfconfigRoot] :: StaticFilesConfig -> !FilePath
[sfconfigHosts] :: StaticFilesConfig -> !Set Host
[sfconfigListings] :: StaticFilesConfig -> !Bool
[sfconfigMiddleware] :: StaticFilesConfig -> ![MiddlewareConfig]
[sfconfigTimeout] :: StaticFilesConfig -> !Maybe Int
[sfconfigSsl] :: StaticFilesConfig -> !SSLConfig
data KeterConfig
KeterConfig :: FilePath -> PortSettings -> !NonEmptyVector ListeningPort -> Maybe Text -> !Vector (Stanza ()) -> Bool -> !Int -> !Int -> !Map Text Text -> !Int -> !Maybe Port -> !Maybe FilePath -> !Maybe FilePath -> !Maybe FilePath -> !Bool -> !Maybe Text -> KeterConfig
[kconfigDir] :: KeterConfig -> FilePath
[kconfigPortPool] :: KeterConfig -> PortSettings
[kconfigListeners] :: KeterConfig -> !NonEmptyVector ListeningPort
[kconfigSetuid] :: KeterConfig -> Maybe Text
[kconfigBuiltinStanzas] :: KeterConfig -> !Vector (Stanza ())
[kconfigIpFromHeader] :: KeterConfig -> Bool
-- | External HTTP port when generating APPROOTs.
[kconfigExternalHttpPort] :: KeterConfig -> !Int
-- | External HTTPS port when generating APPROOTs.
[kconfigExternalHttpsPort] :: KeterConfig -> !Int
-- | Environment variables to be passed to all apps.
[kconfigEnvironment] :: KeterConfig -> !Map Text Text
-- | Maximum request time in milliseconds per connection.
[kconfigConnectionTimeBound] :: KeterConfig -> !Int
-- | Port for the cli to listen on
[kconfigCliPort] :: KeterConfig -> !Maybe Port
[kconfigUnknownHostResponse] :: KeterConfig -> !Maybe FilePath
[kconfigMissingHostResponse] :: KeterConfig -> !Maybe FilePath
[kconfigProxyException] :: KeterConfig -> !Maybe FilePath
[kconfigRotateLogs] :: KeterConfig -> !Bool
[kconfigHealthcheckPath] :: KeterConfig -> !Maybe Text
data Stanza port
Stanza :: StanzaRaw port -> RequiresSecure -> Stanza port
data StanzaRaw port
StanzaStaticFiles :: !StaticFilesConfig -> StanzaRaw port
StanzaRedirect :: !RedirectConfig -> StanzaRaw port
StanzaWebApp :: !WebAppConfig port -> StanzaRaw port
StanzaReverseProxy :: !ReverseProxyConfig -> ![MiddlewareConfig] -> !Maybe Int -> StanzaRaw port
StanzaBackground :: !BackgroundConfig -> StanzaRaw port
type ProxyAction = (ProxyActionRaw, RequiresSecure)
-- | An action to be performed for a requested hostname.
--
-- This datatype is very similar to Stanza, but is necessarily separate
-- since:
--
--
-- - Webapps will be assigned ports.
-- - Not all stanzas have an associated proxy action.
--
data ProxyActionRaw
PAPort :: Port -> !Maybe Int -> ProxyActionRaw
PAStatic :: StaticFilesConfig -> ProxyActionRaw
PARedirect :: RedirectConfig -> ProxyActionRaw
PAReverseProxy :: ReverseProxyConfig -> ![MiddlewareConfig] -> !Maybe Int -> ProxyActionRaw
data RedirectDest
RDUrl :: !Text -> RedirectDest
RDPrefix :: !IsSecure -> !Host -> !Maybe Port -> RedirectDest
data RedirectAction
RedirectAction :: !SourcePath -> !RedirectDest -> RedirectAction
data SourcePath
SPAny :: SourcePath
SPSpecific :: !Text -> SourcePath
data ListeningPort
LPSecure :: !HostPreference -> !Port -> !FilePath -> !Vector FilePath -> !FilePath -> !Bool -> ListeningPort
LPInsecure :: !HostPreference -> !Port -> ListeningPort
data AppInput
AIBundle :: !FilePath -> !EpochTime -> AppInput
AIData :: !BundleConfig -> AppInput
data BackgroundConfig
BackgroundConfig :: !FilePath -> !Vector Text -> !Map Text Text -> !RestartCount -> !Word -> !Set Text -> BackgroundConfig
[bgconfigExec] :: BackgroundConfig -> !FilePath
[bgconfigArgs] :: BackgroundConfig -> !Vector Text
[bgconfigEnvironment] :: BackgroundConfig -> !Map Text Text
[bgconfigRestartCount] :: BackgroundConfig -> !RestartCount
[bgconfigRestartDelaySeconds] :: BackgroundConfig -> !Word
[bgconfigForwardEnv] :: BackgroundConfig -> !Set Text
data RestartCount
UnlimitedRestarts :: RestartCount
LimitedRestarts :: !Word -> RestartCount
-- | Whether we should force redirect to HTTPS routes.
type RequiresSecure = Bool
-- | Manages a pool of available ports and allocates them.
module Keter.PortPool
data PortPool
-- | Gets an unassigned port number.
getPort :: PortPool -> KeterM cfg (Either SomeException Port)
-- | Return a port to the recycled collection of the pool. Note that
-- recycling puts the new ports at the end of the queue (FIFO), so that
-- if an application holds onto the port longer than expected, there
-- should be no issues.
releasePort :: PortPool -> Port -> IO ()
start :: PortSettings -> IO PortPool
module Keter.HostManager
data HostManager
type Reservations = Set Host
-- | Reserve the given hosts so that no other application may use them.
-- Does not yet enable any action. The semantics are:
--
--
-- - If a requested host is currently actively used or by an app of the
-- same name, it is considered reserved.
-- - If a requested host is currently reserved by an app of the same
-- name, it is considered an error in calling this API. Only one app
-- reservation can happen at a time.
-- - If any requested host is currently used or reserved by an app with
-- a different name, then those values are returned as
-- Left.
-- - Otherwise, the hosts which were reserved are returned as
-- Right. This does not include previously active
-- hosts.
--
reserveHosts :: AppId -> Set Host -> KeterM HostManager Reservations
-- | Forget previously made reservations.
forgetReservations :: AppId -> Reservations -> KeterM HostManager ()
-- | Activate a new app. Note that you must first reserve the
-- hostnames you'll be using.
activateApp :: AppId -> Map Host (ProxyAction, Credentials) -> KeterM HostManager ()
deactivateApp :: AppId -> Set Host -> KeterM HostManager ()
reactivateApp :: AppId -> Map Host (ProxyAction, Credentials) -> Set Host -> KeterM HostManager ()
lookupAction :: HostManager -> HostBS -> IO (Maybe (ProxyAction, Credentials))
start :: IO HostManager
module Keter.App
data App
data AppStartConfig
AppStartConfig :: !TempFolder -> !Maybe (Text, (UserID, GroupID)) -> !ProcessTracker -> !HostManager -> !PortPool -> !Plugins -> !KeterConfig -> AppStartConfig
[ascTempFolder] :: AppStartConfig -> !TempFolder
[ascSetuid] :: AppStartConfig -> !Maybe (Text, (UserID, GroupID))
[ascProcessTracker] :: AppStartConfig -> !ProcessTracker
[ascHostManager] :: AppStartConfig -> !HostManager
[ascPortPool] :: AppStartConfig -> !PortPool
[ascPlugins] :: AppStartConfig -> !Plugins
[ascKeterConfig] :: AppStartConfig -> !KeterConfig
start :: AppId -> AppInput -> KeterM AppStartConfig App
reload :: AppInput -> KeterM App ()
-- | Get the modification time of the bundle file this app was launched
-- from, if relevant.
getTimestamp :: App -> STM (Maybe EpochTime)
terminate :: KeterM App ()
-- | within an stm context we can show a lot more then the show instance
-- can do
showApp :: App -> STM Text
instance GHC.Show.Show Keter.App.App
instance GHC.Show.Show Keter.App.RunningWebApp
-- | Used for management of applications.
module Keter.AppManager
data AppManager
data Action
Reload :: AppInput -> Action
Terminate :: Action
perform :: AppId -> Action -> KeterM AppManager ()
-- | Reset which apps are running.
--
--
-- - Any app not listed here that is currently running will be
-- terminated.
-- - Any app listed here that is currently running will be
-- reloaded.
-- - Any app listed here that is not currently running will be
-- started.
--
reloadAppList :: Map Appname (FilePath, EpochTime) -> KeterM AppManager ()
addApp :: FilePath -> KeterM AppManager ()
terminateApp :: Appname -> KeterM AppManager ()
initialize :: KeterM AppStartConfig AppManager
renderApps :: AppManager -> STM Text
instance GHC.Show.Show Keter.AppManager.Action
module Keter.Cli
launchCli :: KeterM CliStates ()
data CliStates
MkCliStates :: !AppManager -> !Port -> CliStates
[csAppManager] :: CliStates -> !AppManager
[csPort] :: CliStates -> !Port
-- | A light-weight, minimalistic reverse HTTP proxy.
module Keter.Proxy
reverseProxy :: ListeningPort -> KeterM ProxySettings ()
makeSettings :: HostManager -> KeterM KeterConfig ProxySettings
data ProxySettings
MkProxySettings :: (ByteString -> IO (Maybe (ProxyAction, Credentials))) -> !Manager -> Bool -> Int -> !Maybe ByteString -> (ByteString -> ByteString) -> ByteString -> ByteString -> ProxySettings
-- | Mapping from virtual hostname to port number.
[psHostLookup] :: ProxySettings -> ByteString -> IO (Maybe (ProxyAction, Credentials))
[psManager] :: ProxySettings -> !Manager
[psIpFromHeader] :: ProxySettings -> Bool
[psConnectionTimeBound] :: ProxySettings -> Int
[psHealthcheckPath] :: ProxySettings -> !Maybe ByteString
[psUnknownHost] :: ProxySettings -> ByteString -> ByteString
[psMissingHost] :: ProxySettings -> ByteString
[psProxyException] :: ProxySettings -> ByteString
data TLSConfig
TLSConfig :: !Settings -> !FilePath -> !FilePath -> Maybe Config -> TLSConfig
module Keter.Main
keter :: FilePath -> [FilePath -> IO Plugin] -> IO ()