Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Revel profileapp.conf


May 15, 2021 Revel


Table of contents


Revel Profile Overview

app.conf a profile of the Revel program that uses the goconfig syntax, similar to Microsoft's INI file.

Here's an example:

app.name=chat
app.secret=pJLzyoiDe17L36mytqC912j81PfTiolHm1veQK6Grn1En3YFdB5lvEHVTwFEaWvj
http.addr=
http.port=9000

[dev]
results.pretty=true
watch=true

log.trace.output = off
log.info.output  = stderr
log.warn.output  = stderr
log.error.output = stderr

[prod]
results.pretty=false
watch=false

log.trace.output = off
log.info.output  = off
log.warn.output  = %(app.name)s.log
log.error.output = %(app.name)s.log

Each segment is a run mode. T he top key (not in any segment) is valid for all operating modes. T his allows the default values to apply in all modes and are override as needed. [prod] only used in 生产 mode.

Dev and prod modes are defined by default in the new Revel program, and you can also customize the segments you need. When the program starts, select the run mode based on the parameters provided by the (command line tool) "revel run".

Custom properties

Developers can customize keys and revel.Config access them. Here are some simple apis.

Built-in properties

Application settings

app.name

Application name for console output and development of web pages.

For example:

app.name = Booking example application

Default: No value


app.secret

Keys are used for password operations ( revel.Sign )。 R evel uses it internally to sign session cookies. Setting to empty disables the signature.

When you create a new project with revel new it is set to a random string.

For example:

app.secret = pJLzyoiDe17L36mytqC912j81PfTiolHm1veQK6Grn1En3YFdB5lvEHVTwFEaWvj

Default: No value

HTTP settings

http.port

The listening port

For example:

http.port = 9000

http.addr

Listen to the ip address

In Linux, an empty string represents a wildcard - in Windows, an empty string is converted "localhost"

Default: ""


harness.port

Specifies the port for the application to listen on, when run by the harness. F or example, when the harness is running, it will listen on http.port , run the application on harness.port , and reverse-proxy requests. Without the harness, the application listens on http.port directly.

By default, a random free port is selected. T his is only necessary by the program to restrict socket access to the environment when the runtime settings. B y default, a random free port will be chosen. This is only necessary to set when running in an environment that restricts socket access by the program.

Default: 0


http.ssl

If true, the Revel Web server will configure itself to accept SSL connections. This requires an X509 certificate and a key file.

Default: false

http.sslcert

Specify the path to the X509 certificate file

Default: ""

http.sslkey

Specifies the path to the X509 certificate key

Default: ""

The result of the response

results.chunked

Determines whether block encoding is used when the template is rendered. Block encoding reduces the time it takes to send the first byte to the client (before the entire template has fully rendered the data).

Default: false


results.pretty

Configure RenderXml RenderJson XML/JSON in indentation formats. For example:

results.pretty = true

Default: false

International (i18n)

i18n.default_language

Specify the default language for message translation if the client requests a language that is not confirmed. If not specified, a virtual message is returned.

For example:

i18n.default_language = en

Default: ""


i18n.cookie

Specify the name of the cookie that stores the user's locale

Default: "% (cookie.prefix) _LANG" (reference cookie.prefix)

Monitoring

Revel monitors project changes and supports hot overloading of several types of files. Enable monitoring:

watch = true

If false, disable monitoring, and ignore other related monitoring configuration watch.*

Default: true


watch.templates

If true, Revel monitors template changes and reloads them if necessary.

Default: true


watch.routes

If true, Revel monitors for routes file and reloads if necessary.

Default: true


watch.code

If true, Revel monitors Go code churn and recompiles the code if necessary (running as a reverse proxy).

The code under the app/ (including subdirectdirecters) is monitored.

Default: true

Cookies

The Revel component uses the following cookies by default:

  • REVEL_SESSION
  • REVEL_LANG
  • REVEL_FLASH
  • REVEL_ERRORS

cookie.prefix

Revel uses this property as a prefix for Revel-produced cookies. This allows multiple REVEL applications to run on the same host.

For example

cookie.prefix = MY

The corresponding cookie name is as follows:

  • MY_SESSION
  • MY_LANG
  • MY_FLASH
  • MY_ERRORS

Default: "REVEL"

Session

session.expires

Revel uses this property to set the expiration date of the session cookie. R evel parses strings using ParseDuration, with a default value of 30 days. I t can also be set to expire at the end of the session. Note that the behavior of the client depends on the browser's settings, so the results are not always guaranteed.

Template

template.delimiters

Specify the left and right separators of the template
The separator "Left separator, right separator" must be specified in this way.

Default: ""

Format

format.date

Specify the default date format, and Revel uses it in two places:

  • Binding date parameters to time.Time (refer to binding )
  • Use the date template date output the date in the template (refer to the template function). )

Default: "2006-01-02"


format.datetime

Specify the default date-time format, and Revel uses it in two places:

Default: "2006-01-02 15:04"

Database

db.import

Specifies the database/sql driver import path for the DB module.

Default: ""


db.driver

Specify the database/sql driver name (in sql.Open to use).

Default: ""


db.spec

Specify the database/sql data source name (in sql.Open to use).

Default: ""

Build

build.tags

Build tags are used when building programs.

Default: ""

Log

Todo

Cache

The cache module is a simple heap or distributed cache interface

cache.expires

Set the cache expiration time. T he caller in the program uses the constant cache.DEFAULT gets.

It is to accept time.ParseDuration string.

(The default value cannot be specified as FOREVER at this FOREVER )

Default: "1h" (1 hour)


cache.memcached

If true, the cache module uses memcached instead of the memory cache.

Default: false


cache.hosts

A comma separates the memcached host list. C ache entries are automatically shrapned into available hosts using a determined host name cache key. Hosts may be listed multiple times to increase shared cache space.

Default: ""

Schedule the task

The Scheduled Tasks module allows you to run scheduled or temporary tasks

Schedule

Timesheets can be configured with keys.

cron.schedulename = @hourly

The schedule's schedule schedule time can be used when submitting tasks in the executor. For example:

jobs.Schedule("cron.schedulename", job)

jobs.pool

The number of tasks allowed at the same time. For example:

jobs.pool = 4

If it is 0, there is no quantity limit

Default: 10


jobs.selfconcurrent

If true, allows a task to run, even if the instance of the task is still in the process.

Default: false

Module

The module adds the module to the application by specifying the import path. For example:

module.testrunner = github.com/revel/revel/modules/testrunner

Development plan

  • Allows you to configure values with command-line parameters or otherly specify values on the command-line.