Skip to content

环境变量

¥Environment Variables

你可以在 Meteor 应用中使用的环境变量列表。

¥List of environment variables that you can use with your Meteor application.

BIND_IP

(生产)

¥(production)

通过 IP 地址将应用服务器绑定到特定网络接口,例如:BIND_IP=192.168.0.2

¥Bind the application server to a specific network interface by IP address, for example: BIND_IP=192.168.0.2.

另请参阅:PORT

¥See also: PORT.

在开发中,这可以通过 meteor run --port a.b.c.d:port 来实现。

¥In development, this can be accomplished with meteor run --port a.b.c.d:port.

DDP_DEFAULT_CONNECTION_URL

(开发、生产)

¥(develoment, production)

在某些情况下,Meteor 客户端使用与 ROOT_URL 服务器不同的 DDP 服务器是很有价值的。

¥There are some situations where it is valuable for the meteor client to use a different DDP server than the ROOT_URL server.

在运行 Meteor 服务器(开发:meteor run 或生产:node main.js)时设置 DDP_DEFAULT_CONNECTION_URL 会将 DDP 服务器设置为 DDP_DEFAULT_CONNECTION_URL 中的值。

¥Setting DDP_DEFAULT_CONNECTION_URL when running a meteor server (development: meteor run or production: node main.js) will set the DDP server to the value in DDP_DEFAULT_CONNECTION_URL.

在构建(meteor build)时设置 DDP_DEFAULT_CONNECTION_URL 将定义用于 cordova 构建的 DDP 服务器。

¥Setting DDP_DEFAULT_CONNECTION_URL when building (meteor build) will define the DDP server for cordova builds.

DISABLE_WEBSOCKETS

(开发、生产)

¥(development, production)

如果你自己的部署平台不支持 WebSockets,或者你确信自己不会从中受益,则使用 DISABLE_WEBSOCKETS=1 设置此变量将明确禁用 WebSockets 并强制使用后备轮询机制,而不是尝试自动检测这一点。

¥In the event that your own deployment platform does not support WebSockets, or you are confident that you will not benefit from them, setting this variable with DISABLE_WEBSOCKETS=1 will explicitly disable WebSockets and forcibly resort to the fallback polling-mechanism, instead of trying to detect this automatically.

DISABLE_SOCKJS

(开发、生产)

¥(development, production)

如果你想在客户端使用原生 WebSocket 实现而不是 SockJS,请设置 DISABLE_SOCKJS=1,例如,如果你想在服务器端使用自定义 WebSocket 实现(例如 uWebSockets.js)。

¥Set DISABLE_SOCKJS=1 if you want to use the native WebSocket implementation instead of SockJS on the client side, for example, if you want to use a custom WebSocket implementation (e.g. uWebSockets.js) on the server side.

HTTP_FORWARDED_COUNT

(生产)

¥(production)

将其设置为你在 Meteor 应用之前运行的代理数量。例如,如果在你的 Meteor 应用之前有一个 NGINX 服务器充当代理,则可以设置 HTTP_FORWARDED_COUNT=1。如果你在该 NGINX 服务器前面有一个负载均衡器,则计数为 2。

¥Set this to however many number of proxies you have running before your Meteor application. For example, if have an NGINX server acting as a proxy before your Meteor application, you would set HTTP_FORWARDED_COUNT=1. If you have a load balancer in front of that NGINX server, the count is 2.

MAIL_URL

(开发、生产)

¥(development, production)

使用此变量设置用于发送电子邮件的 SMTP 服务器。PostmarkMandrillMailGunSendGrid(以及其他公司)是可以提供此服务的公司。MAIL_URL 包含用于连接到 SMTP 服务器的所有信息,并且像 URL 一样,应该看起来像 smtp://user:pass@yourservice.com:587smtps://user:pass@yourservice.com:465

¥Use this variable to set the SMTP server for sending e-mails. Postmark, Mandrill, MailGun and SendGrid (among others) are companies who can provide this service. The MAIL_URL contains all of the information for connecting to the SMTP server and, like a URL, should look like smtp://user:pass@yourservice.com:587 or smtps://user:pass@yourservice.com:465.

smtp:// 表单适用于支持通过 STARTTLS 加密的邮件服务器或根本不使用加密的邮件服务器,最常见于端口 587 上的服务器,有时也常见于端口 25 上的服务器。另一方面,如果服务器仅支持 TLS/SSL(并且不支持使用 STARTTLS 进行连接升级),则应使用 smtps:// 形式(s 代表 "secure"),并且最常用于端口 465 上的服务器。

¥The smtp:// form is for mail servers which support encryption via STARTTLS or those that do not use encryption at all and is most common for servers on port 587 and sometimes port 25. On the other hand, the smtps:// form (the s stands for "secure") should be used if the server only supports TLS/SSL (and does not support connection upgrade with STARTTLS) and is most common for servers on port 465.

METEOR_DISABLE_OPTIMISTIC_CACHING

(生产)

¥(production)

运行 meteor buildmeteor deploy 时,你可以设置 METEOR_DISABLE_OPTIMISTIC_CACHING=1 以加快构建时间。

¥When running meteor build or meteor deploy you can set METEOR_DISABLE_OPTIMISTIC_CACHING=1 to speed up your build time.

由于乐观内存缓存是构建系统中内存密集程度较高的部分之一,因此设置环境变量 METEOR_DISABLE_OPTIMISTIC_CACHING=1 可以帮助改善 Meteor 构建期间的内存使用情况,这似乎可以缩短总构建时间。此配置非常安全,因为乐观缓存的整个目的是跟踪以前的结果以供将来重建,但在 Meteor builddeploy 的情况下,只有一个初始构建,因此额外的簿记是不必要的。

¥Since optimistic in-memory caching is one of the more memory-intensive parts of the build system, setting the environment variable METEOR_DISABLE_OPTIMISTIC_CACHING=1 can help improve memory usage during meteor build, which seems to improve the total build times. This configuration is perfectly safe because the whole point of optimistic caching is to keep track of previous results for future rebuilds, but in the case of meteor build or deploy there's only ever one initial build, so the extra bookkeeping is unnecessary.

METEOR_PROFILE

(开发)

¥(development)

在开发中,你可能需要诊断导致构建开始花费很长时间的原因。要获取构建期间的调用堆栈和时间,你可以运行 METEOR_PROFILE=1 meteor

¥In development, you may need to diagnose what has made builds start taking a long time. To get the callstack and times during builds, you can run METEOR_PROFILE=1 meteor.

METEOR_PACKAGE_DIRS

(开发、生产)

¥(development, production)

要查找的本地包目录的冒号分隔列表,位于正常应用结构之外,例如:METEOR_PACKAGE_DIRS="/usr/local/my_packages/"。请注意,这曾经是 PACKAGE_DIRS,但在 Meteor 1.4.2 中发生了变化。

¥Colon-delimited list of local package directories to look in, outside your normal application structure, for example: METEOR_PACKAGE_DIRS="/usr/local/my_packages/". Note that this used to be PACKAGE_DIRS but was changed in Meteor 1.4.2.

METEOR_SETTINGS

(生产)

¥(production)

在生产模式下运行打包应用时,使用 METEOR_SETTINGS='{ "server_only_setting": "foo", "public": { "client_and_server_setting": "bar" } }' 传递包含设置的 JSON 字符串。

¥When running your bundled application in production mode, pass a string of JSON containing your settings with METEOR_SETTINGS='{ "server_only_setting": "foo", "public": { "client_and_server_setting": "bar" } }'.

在开发中,这可以通过 meteor --settings [file.json] 来实现,以便在更改设置时提供完全响应。这些设置在这里只是作为字符串传递。有关更多信息,请参阅 Meteor.settings 文档。

¥In development, this is accomplished with meteor --settings [file.json] in order to provide full-reactivity when changing settings. Those settings are simply passed as a string here. Please see the Meteor.settings documentation for further information.

METEOR_SQLITE_JOURNAL_MODE

(开发)

¥(development)

Meteor 软件包目录默认使用 WAL SQLite 日志模式。可以通过设置 METEOR_SQLITE_JOURNAL_MODE 来修改包目录的日志模式。

¥The Meteor package catalog uses the WAL SQLite Journal Mode by default. The Journal mode for the package catalog can be modifed by setting METEOR_SQLITE_JOURNAL_MODE.

Windows Linux 子系统 (WSL) 上运行多个并发 Meteor 服务器时,一些 Meteor 开发者发现包目录存在问题。设置环境变量 METEOR_SQLITE_JOURNAL_MODE=TRUNCATE 可以解决这个问题。

¥When running multiple concurrent meteor servers on Windows Subsystem for Linux (WSL) some meteor developers have seen issues with the package catalog. Setting the environment variable METEOR_SQLITE_JOURNAL_MODE=TRUNCATE can overcome the issue.

MONGO_OPLOG_URL

(开发、生产)

¥(development, production)

MongoDB 服务器 oplog URL。如果你正在使用副本集(你应该这样做),请像这样构造此 URL:MONGO_OPLOG_URL="mongodb://user:password@myserver.com:10139/local?replicaSet=(your replica set)&authSource=(your auth source)"

¥MongoDB server oplog URL. If you're using a replica set (which you should), construct this url like so: MONGO_OPLOG_URL="mongodb://user:password@myserver.com:10139/local?replicaSet=(your replica set)&authSource=(your auth source)"

MONGO_URL

(开发、生产)

¥(development, production)

MongoDB 服务器 URL。提供一个完全限定的 URL(或逗号分隔的 URL 列表),如 MONGO_URL="mongodb://user:password@myserver.com:10139"。有关更多信息,请参阅 MongoDB 文档

¥MongoDB server URL. Give a fully qualified URL (or comma-separated list of URLs) like MONGO_URL="mongodb://user:password@myserver.com:10139". For more information see the MongoDB docs.

PORT

(生产)

¥(production)

应用应该监听哪个端口,例如:PORT=3030

¥Which port the app should listen on, for example: PORT=3030

另请参阅:BIND_IP

¥See also: BIND_IP.

在开发中,这可以通过 meteor run --port <port> 来实现。

¥In development, this can be accomplished with meteor run --port <port>.

ROOT_URL

(开发、生产)

¥(development, production)

用于通过 accounts 包等生成应用的 URL。为你的应用提供完整的 URL,如下所示:ROOT_URL="https://www.myapp.com"

¥Used to generate URLs to your application by, among others, the accounts package. Provide a full URL to your application like this: ROOT_URL="https://www.myapp.com".

TOOL_NODE_FLAGS

(开发、生产)

¥(development, production)

用于将标志/变量传递给 Meteor 构建中的 Node。例如,你可以使用它将链接传递给 icu 数据:TOOL_NODE_FLAGS="--icu-data-dir=node_modules/full-icu" 有关可用标志的完整列表,请参阅 Node 文档

¥Used to pass flags/variables to Node inside Meteor build. For example you can use this to pass a link to icu data: TOOL_NODE_FLAGS="--icu-data-dir=node_modules/full-icu" For full list of available flags see the Node documentation.

UNIX_SOCKET_GROUP

(生产)

¥(production)

这将覆盖在 UNIX_SOCKET_PATH 中配置的套接字文件的默认 UNIX 组。它可以设置为组名或数字 gid。

¥This overrides the default UNIX group of the socket file configured in UNIX_SOCKET_PATH. It can be set to a group name or a numerical gid.

UNIX_SOCKET_PATH

(生产)

¥(production)

将 Meteor 的 HTTP 服务器配置为监听 UNIX 套接字文件路径(例如 UNIX_SOCKET_PATH=/tmp/meteor.sock)而不是 TCP 端口。这在运行本地反向代理服务器(如 Nginx)来处理客户端 HTTP 请求并将其定向到你的 Meteor 应用时很有用。利用 UNIX 域套接字在同一主机上进行本地通信可避免基于 TCP 的通信所需的操作系统开销,还可以提高安全性。此 UNIX 套接字文件在 Meteor 启动时创建,在 Meteor 退出时删除。

¥Configure Meteor's HTTP server to listen on a UNIX socket file path (e.g. UNIX_SOCKET_PATH=/tmp/meteor.sock) instead of a TCP port. This is useful when running a local reverse proxy server like Nginx to handle client HTTP requests and direct them to your Meteor application. Leveraging UNIX domain sockets for local communication on the same host avoids the Operating System overhead required by TCP based communication and can also improve security. This UNIX socket file is created when Meteor starts and removed when Meteor exits.

UNIX_SOCKET_PERMISSIONS

(生产)

¥(production)

这将覆盖在 UNIX_SOCKET_PATH 中配置的 UNIX 套接字文件的默认 UNIX 文件权限。例如,UNIX_SOCKET_PERMISSIONS=660 将为用户和组设置读/写权限。

¥This overrides the default UNIX file permissions on the UNIX socket file configured in UNIX_SOCKET_PATH. For example, UNIX_SOCKET_PERMISSIONS=660 would set read/write permissions for both the user and group.