2015-12-02 70 views
-1

我想在生產模式中解除我的帆。當我運行帆升降機時--prod --verbose,我得到一堆錯誤。 我的local.js文件看起來像這樣。無法在生產模式下提升帆。(帆升降機 - 產品 - 動力不工作)

/** 
    * Local environment settings 
* 
* While you're developing your app, this config file should include 
* any settings specifically for your development computer (db passwords, etc.) 
* When you're ready to deploy your app in production, you can use this file 
* for configuration options on the server where it will be deployed. 
* 
* 
* PLEASE NOTE: 
*  This file is included in your .gitignore, so if you're using git 
*  as a version control solution for your Sails app, keep in mind that 
*  this file won't be committed to your repository! 
* 
*  Good news is, that means you can specify configuration for your local 
*  machine in this file without inadvertently committing personal information 
*  (like database passwords) to the repo. Plus, this prevents other members 
*  of your team from commiting their local configuration changes on top of yours. 
* 
* 
* For more information, check out: 
* http://sailsjs.org/#documentation 
*/ 
var config={ 

development:{ 
    connections: { 

      mongo: { 
      adapter: 'sails-mongo', 
      host: 'localhost', 
      user: '', 
      password: '', 
      database: 'mydata', 
      schema: true 
     } 
    }, 
    mailer:{ 
     hostUrl:'http://localhost:1337/', 
     emailConfirm:'confirm/', 
     inviteMoreFriends:'myspace' 
    }, 
    geoSpatial:{ 
     radiusOfEarth:6375, 
     radius:3, 
     maxRecords:20 
    }, 
    facebook:{ 
     clientID: "CLIENT ID", 
     clientSecret: "SECRET", 
     callbackURL: "http://www.EXAMPLE.com:1337/auth/facebook/callback" 
    } 
} 
} 
module.exports = { 


// The `port` setting determines which TCP port your app will be deployed on 
// Ports are a transport-layer concept designed to allow many different 
// networking applications run at the same time on a single computer. 
// More about ports: http://en.wikipedia.org/wiki/Port_(computer_networking) 
// 
// By default, if it's set, Sails uses the `PORT` environment variable. 
// Otherwise it falls back to port 1337. 
// 
// In production, you'll probably want to change this setting 
// to 80 (http://) or 443 (https://) if you have an SSL certificate 

port: process.env.PORT || 1337, 


// The runtime "environment" of your Sails app is either 'development' or 'production'. 
// 
// In development, your Sails app will go out of its way to help you 
// (for instance you will receive more descriptive error and debugging output) 
// 
// In production, Sails configures itself (and its dependencies) to optimize performance. 
// You should always put your app in production mode before you deploy it to a server- 
// This helps ensure that your Sails app remains stable, performant, and scalable. 
// 
// By default, Sails sets its environment using the `NODE_ENV` environment variable. 
// If NODE_ENV is not set, Sails will run in the 'development' environment. 

environment: process.env.NODE_ENV || 'development', 


development: { 
    //config is placed as the attributes needed by aws config node module 
    aws: { 
     region: 'REGION', 
     accessKeyId: 'KEY ID', 
     secretAccessKey: 'SECRET', 
     cloudFrontCDN: 'EXAMPLE.cloudfront.net' 
    }, 
    s3: { 
     Bucket: 'MY_BUCKET', 
     endpoint: 'ENDPOINT', 
     imageUrl: 'URL' 
    }, 
    uploads: { 
     thumbnails: __dirname + '/../uploads/thumbnails/' 
    } 



}, 
likeprod: { 
    //config is placed as the attributes needed by aws config node module 
    aws: { 
     region: 'REGION', 
     accessKeyId: 'KEY ID', 
     secretAccessKey: 'SECRET', 
     cloudFrontCDN: 'EXAMPLE.cloudfront.net' 
    }, 
    s3: { 
     Bucket: 'MY_BUCKET', 
     endpoint: 'ENDPOINT', 
     imageUrl: 'URL' 
    }, 
    uploads: { 
     thumbnails: __dirname + '/../uploads/thumbnails/' 
    } 


}, 

mandrillApiKey:"API_KEY", 
twilio:{ 
    accountSid:'SECRET', 
    authToken:'TOKEN' 
}, 
metaPublic:{ 
    groupBookNumber:'' 
}, 

    connections:config[process.env.NODE_ENV].connections, 
    mailer:config[process.env.NODE_ENV].mailer, 
    geoSpatial:config[process.env.NODE_ENV].geoSpatial, 
    facebook:config[process.env.NODE_ENV].facebook, 

//TODO: refactor the config[environment] as for connections 
current: function() { 
    return sails.config[sails.config.environment] 
} 

};

當我運行帆升降機 - 產品。我收到這個錯誤。

$ sails lift --prod --verbose 

info: Starting app... 

verbose: Please run `npm install coffee-script` to use coffescript  (skipping for now) 
verbose: Setting Node environment... 
verbose: moduleloader hook loaded successfully. 
verbose: Loading app config... 

/home/vgulp/Desktop/config/local.js:136 
connections:config[process.env.NODE_ENV].connections, 
             ^
TypeError: Cannot read property 'connections' of undefined 
at Object.<anonymous> (/home/Desktop/vka/config/local.js:136:45) 
at Module._compile (module.js:456:26) 
at Object.Module._extensions..js (module.js:474:10) 
at Module.load (module.js:356:32) 
at Function.Module._load (module.js:312:12) 
at Module.require (module.js:364:17) 
at require (module.js:380:17) 
at  /home/Desktop/vka/node_modules/sails/node_modules/include-all/index.js:129:29 
at Array.forEach (native) 
at requireAll (/home/Desktop/vka/node_modules/sails/node_modules/include-all/index.js:44:9) 
at buildDictionary (/home/Desktop/vka/node_modules/sails/node_modules/sails-build-dictionary/index.js:68:14) 
at Function.module.exports.aggregate (/home/Desktop/vka/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9) 
at Array.loadOtherConfigFiles [as 0] (/home/Desktop/vka/node_modules/sails/lib/hooks/moduleloader/index.js:102:22) 
at /home/Desktop/vka/node_modules/sails/node_modules/async/lib/async.js:459:38 
at Array.forEach (native) 
at _each (/home/Desktop/vka/node_modules/sails/node_modules/async/lib/async.js:32:24) 
at Object.async.auto (/home/Desktop/vka/node_modules/sails/node_modules/async/lib/async.js:430:9) 

任何人都可以提出解決方案。

+0

此應用是否部署到Amazon EC2上的實例?您是否檢查過[安全組](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html)以確保1337端口可以通信? – birryree

+0

是的,它部署在亞馬遜EC2上並且端口1337是通暢的。 –

+0

在提供答案後,我完全改變了您的問題。 如果你有一個新的/不同的問題,問一個新的問題,並添加一個評論鏈接到新的問題,以便人們可以根據需要跟進 –

回答

2

你別有在local.jsproduction指定連接

(正如您從您的桌面運行)由於錯誤說得好,

connections:config[process.env.NODE_ENV].connections, ^ TypeError: Cannot read property 'connections' of undefined

process.env.NODE_ENVproduction時運行在--prod

var config = { 

    development: { 
     connections: { 

      mongo: { 
       adapter: 'sails-mongo', 
       host: 'localhost', 
       user: '', 
       password: '', 
       database: 'mydata', 
       schema: true 
      } 
     }, 
     mailer: { 
      hostUrl: 'http://localhost:1337/', 
      emailConfirm: 'confirm/', 
      inviteMoreFriends: 'myspace' 
     }, 
     geoSpatial: { 
      radiusOfEarth: 6375, 
      radius: 3, 
      maxRecords: 20 
     }, 
     facebook: { 
      clientID: "CLIENT ID", 
      clientSecret: "SECRET", 
      callbackURL: "http://www.EXAMPLE.com:1337/auth/facebook/callback" 
     } 
    }, 
    production: { 
     connections: { 

      mongo: { 
       adapter: 'sails-mongo', 
       host: 'localhost', 
       user: '', 
       password: '', 
       database: 'mydata', 
       schema: true 
      } 
     }, 
     mailer: { 
      hostUrl: 'http://localhost:1337/', 
      emailConfirm: 'confirm/', 
      inviteMoreFriends: 'myspace' 
     }, 
     geoSpatial: { 
      radiusOfEarth: 6375, 
      radius: 3, 
      maxRecords: 20 
     }, 
     facebook: { 
      clientID: "CLIENT ID", 
      clientSecret: "SECRET", 
      callbackURL: "http://www.EXAMPLE.com:1337/auth/facebook/callback" 
     } 
    } 
} 
+0

它的工作,但我得到一個新的bootstrap.js錯誤。 –

+0

/bootstrap.js:165 mkdirp(sails.config.current()uploads.thumbnails,函數(ERR){ ^ 類型錯誤:在createUploadDirectories無法讀取的不確定 財產 '上傳'(/家/ vgulp /桌面/funvgulp/config/bootstrap.js:165:38) –

+1

@VaibhavKumarAmbeshta用'bootstrap.js'的內容更新問題或者開始一個新問題。 – MjZac

3

[編輯:下面的答案是基於其完全被作者改變了原來的問題]

你的船帆的應用程序需要在生產模式解除或者你需要指定端口在你的配置中使用文件。

生產模式運行端口的Express服務器80

是您的AWS實例安裝解除在生產模式下的應用程序?

http://sailsjs.org/documentation/anatomy/my-app/config/env/production-js

+0

是的,我可以解除生產模式中的帆應用程序,我可以通過鍵入xx來訪問它。 xx.xxx.xx:1337。如何在不指定端口的情況下使用AWS公共IP訪問應用程序。 –

+0

您必須提升端口80(默認的非SSL Web客戶端端口)。這是在生產中吊裝時的默認端口使用。 – Meeker