2015-12-02 72 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