Skip to content

Commit 56ef57a

Browse files
authored
Document Environment and the default differences between Prod/Dev (#2090)
* Document Environment and the default differences between Production/Development * Clarify that Environment is set by devenv up and deploy-to-nixos * Link to Guide when referring to guide
1 parent 5d703aa commit 56ef57a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

IHP/Environment.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
module IHP.Environment where
22
import IHP.Prelude
33

4+
-- | The 'Environment' type is used to switch between development and production configurations.
5+
--
6+
-- When running 'devenv up', this will be set to 'Development', while 'deploy-to-nixos' will set it to 'Production'.
7+
-- You can also manually set it with 'option Development' or 'option Production' in your Config.hs, or via the 'IHP_ENV' environment variable.
8+
--
9+
-- You can check the current environment using 'isDevelopment', 'isProduction', or 'isEnvironment' if you want to change behaviour based on the environment.
10+
-- IHP by default implements the following differences:
11+
--
12+
-- - Static file caching: In 'Development', browser cache is disabled (max-age=0). In 'Production', max-age is forever, with asset hashes for invalidation. See 'initStaticApp'.
13+
-- - Logger: In 'Development', logging uses the default format. In 'Production', it uses an Apache-style logger and higher log level. See 'ihpDefaultConfig'.
14+
-- - Background workers: In 'Development', a development job worker server is started automatically. In 'Production', you need to manually start a separate RunJobs process. See the [chapter on Jobs in the Guide](https://ihp.digitallyinduced.com/Guide/jobs.html#development-vs-production) for details.
15+
-- - Database connections: The pool idle time is by default shorter in 'Development'. See 'ihpDefaultConfig'.
16+
-- - Error pages: In 'Development', error pages may contain backtraces and details about the code, with links to the IDE. In 'Production', error pages do not contain implementation information.
417
data Environment = Development | Production deriving (Eq, Show)

IHP/FrameworkConfig.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,13 +456,17 @@ isEnvironment environment = ?context.frameworkConfig.environment == environment
456456
-- | Returns 'True' when the application is running in Development mode
457457
--
458458
-- Development mode means that the Development option is configured in Config/Config.hs
459+
--
460+
-- See 'Environment' for documentation on the default differences.
459461
isDevelopment :: (?context :: context, ConfigProvider context) => Bool
460462
isDevelopment = isEnvironment Development
461463
{-# INLINABLE isDevelopment #-}
462464

463465
-- | Returns 'True' when the application is running in Production mode
464466
--
465467
-- Production mode means that the Production option is configured in Config/Config.hs
468+
--
469+
-- See 'Environment' for documentation on the default differences.
466470
isProduction :: (?context :: context, ConfigProvider context) => Bool
467471
isProduction = isEnvironment Production
468472
{-# INLINABLE isProduction #-}

0 commit comments

Comments
 (0)