我正在尝试将在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中。有什么想法吗?
更新:我将主服务器文件更新为#34; 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.
答案 0 :(得分:2)
解决方案是在门户网站的Azure网站的配置选项卡上将平台设置为64位。然后,我在节点项目的根目录下创建了一个IISnode.yml
文件,其中包含以下内容:
loggingEnabled: true
devErrorsEnabled: true
现在,当我通过浏览器访问该站点时,我看到了详细的错误消息,这表明没有配置cloudinary env变量。我将存储在我的项目.env
文件中的内容添加到我的azure网站门户页面的配置选项卡上的应用程序设置中,并修复了所有内容!