簡體   English   中英

為什么sails.js會忽略/config/env/production.js而改用process.env.PORT?

[英]Why does sails.js ignore /config/env/production.js and use process.env.PORT instead?

我已在/config/env/production.js中將端口設置為8080,並將環境變量NODE_ENV設置為production。 但是,當我揚帆起航時,我只能在8000端口啟動它。最終,我意識到我可以設置端口環境變量並獲得正確的結果,但是我更喜歡使用普通的配置文件。 我沒有local.js配置文件,因此不會被覆蓋。 我究竟做錯了什么?

[15:12:50] nodejs @ myserver : /apps/myapi/
$ cat config/env/production.js
/**
 * Production environment settings
 *
 * This file can include shared settings for a production environment,
 * such as API keys or remote database passwords.  If you're using
 * a version control solution for your Sails app, this file will
 * be committed to your repository unless you add it to your .gitignore
 * file.  If your repository will be publicly viewable, don't add
 * any private information to this file!
 *
 */

module.exports = {

  /***************************************************************************
   * Set the default database connection for models in the production        *
   * environment (see config/connections.js and config/models.js )           *
   ***************************************************************************/

  // models: {
  //   connection: 'someMysqlServer'
  // },

  /***************************************************************************
   * Set the port in the production environment to 80                        *
   ***************************************************************************/

  port: 8080,

  /***************************************************************************
   * Set the log level in production environment to "silent"                 *
   ***************************************************************************/

  // log: {
  //   level: "silent"
  // }

};

[15:13:09] nodejs @ myserver : /apps/myapi/
$ sails lift

Starting app...

Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.

               .-..-.

   Sails              <|    .-..-.
   v0.11.2             |\
                      /|.\
                     / || \
                   ,'  |'  \
                .-'.-==|/_--'
                `--'-------'
   __---___--___---___--___---___--___
 ____---___--___---___--___---___--___-__

Server lifted in `/apps/myapi`
To see your app, visit http://localhost:8000
To shut down Sails, press <CTRL> + C at any time.

--------------------------------------------------------
:: Thu Oct 15 2015 15:13:21 GMT+0800 (HKT)

Environment : production
Port        : 8000
--------------------------------------------------------
^C
[15:15:20] nodejs @ myserver : /apps/myapi/
$ export PORT=8080

[15:15:41] nodejs @ myserver : /apps/myapi/
$ sails lift

Starting app...

Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.

               .-..-.

   Sails              <|    .-..-.
   v0.11.2             |\
                      /|.\
                     / || \
                   ,'  |'  \
                .-'.-==|/_--'
                `--'-------'
   __---___--___---___--___---___--___
 ____---___--___---___--___---___--___-__

Server lifted in `/apps/myapi`
To see your app, visit http://localhost:8080
To shut down Sails, press <CTRL> + C at any time.

--------------------------------------------------------
:: Thu Oct 15 2015 15:15:48 GMT+0800 (HKT)

Environment : production
Port        : 8080
--------------------------------------------------------

事實證明,父目錄中存在一個.ENV文件,該文件會自動設置端口環境變量(即使我未設置它)。 我想在這種情況下,讓帆尊重/config/production.js上的環境變量是有意義的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM