1

我正在尝试将 node.js 中内置的普通 keystone.js 启动应用程序部署到 Azure 网站的共享层。

部署后出现错误

The page cannot be displayed because an internal server error has occurred.

我认为可能是因为调用了主服务器文件,keystone.js所以我将其重命名为index.js. 这并没有解决它。

接下来,我认为这可能是一个问题,因为 keystone 默认为端口 3000,所以我在index.js文件中添加了端口信息。这里是:

// Simulate config options from your production environment by
// customising the .env file in your project's root folder.
require('dotenv').load();

// Require keystone
var keystone = require('keystone');

// Initialise Keystone with your project's configuration.
// See http://keystonejs.com/guide/config for available options
// and documentation.

keystone.init({

    'name': 'Magic Site',
    'brand': 'Magic Site',

    'less': 'public',
    'static': 'public',
    'favicon': 'public/favicon.ico',
    'views': 'templates/views',
    'view engine': 'jade',

    'mongo': "redacted",

    'port': process.env.PORT || 1337,

    'auto update': true,
    'session': true,
    'auth': true,
    'user model': 'User',
    'cookie secret': 'redacted'

});

// Load your project's Models

keystone.import('models');

// Setup common locals for your templates. The following are required for the
// bundled templates and layouts. Any runtime locals (that should be set uniquely
// for each request) should be added to ./routes/middleware.js

keystone.set('locals', {
    _: require('underscore'),
    env: keystone.get('env'),
    utils: keystone.utils,
    editable: keystone.content.editable
});

// Load your project's Routes

keystone.set('routes', require('./routes'));

// Setup common locals for your emails. The following are required by Keystone's
// default email templates, you may remove them if you're using your own.

// Configure the navigation bar in Keystone's Admin UI

keystone.set('nav', {
    'posts': ['posts', 'post-categories'],
    'galleries': 'galleries',
    'enquiries': 'enquiries',
    'users': 'users'
});

// Start Keystone to connect to your database and initialise the web server

keystone.start();

仍然没有运气。但是,这在我的本地机器上效果很好,只是在 Azure 中不行。有任何想法吗?

更新:我将我的主服务器文件更新为“server.js”。我做了一些挖掘并查看了 Azure 中的部署日志,发现:

Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling node.js deployment.
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
Deleting file: 'index.js'
Copying file: 'package.json'
Copying file: 'server.js'
Using start-up script server.js from package.json.
Generated web.config.
Node.js versions available on the platform are: 0.6.17, 0.6.20, 0.8.2, 0.8.19, 0.8.26, 0.8.27, 0.10.5, 0.10.18, 0.10.21, 0.10.24, 0.10.26, 0.10.28, 0.10.29.
Selected node.js version 0.10.29. Use package.json file to choose a different version.
Updating iisnode.yml at D:\home\site\wwwroot\iisnode.yml
Finished successfully.
4

1 回答 1

2

解决方案是在门户中 Azure 网站的配置选项卡上将平台设置为 64 位。IISnode.yml然后我在我的节点项目的根目录创建了一个文件,内容如下:

loggingEnabled: true
devErrorsEnabled: true

现在,当我通过浏览器访问该站点时,我看到了详细的错误消息,这表明未配置 cloudinary 环境变量。我将存储在我的项目.env文件中的内容添加到我的 azure 网站门户页面的配置选项卡上的应用程序设置中,从而解决了所有问题!

于 2014-07-29T14:37:13.590 回答