我嘗試天青與節點,並使用Wercker CI構建然後部署通過FTP到Azure。部署應用程序的NodeJS通過FTP Azure不工作
但好像我有一些麻煩這個工作。我正在複製server.js
文件以及package.json
和其他一些資產。但它看起來沒有運行npm install
命令。另外,到達該網站時我收到You do not have permission to view this directory or page.
。
有一個web.config
文件具有以下配置:
<!--
This configuration file is required if iisnode is used to run node processes behind IIS or IIS Express. For more information, visit:
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->
<configuration>
<system.webServer>
<handlers>
<!-- indicates that the app.js file is a node.js application to be handled by the iisnode module -->
<add name="iisnode" path="./server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Don't interfere with requests for logs -->
<rule name="LogFile" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^[a-zA-Z0-9_\-]+\.js\.logs\/\d+\.txt$"/>
</rule>
<!-- Don't interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^\.\/server.js\/debug[\/]?" />
</rule>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<!--<rule name="StaticContent">
<action type="Rewrite" url="./app/assets/{REQUEST_URI}"/>
</rule>-->
<!-- All other URLs are mapped to the Node.js application entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="./server.js"/>
</rule>
</rules>
</rewrite>
<iisnode watchedFiles="*.js;node_modules\*;routes\*.js;views\*.jade;middleware\*.js"/>
</system.webServer>
</configuration>
而且server.js
很簡單,只要:
var http_1 = require('http');
var express = require('express');
var log4js_1 = require('log4js');
var morgan = require('morgan');
var split = require('split2');
// NOTE: Some of the features used are only available in ES6
// do not forget to start the server using `node --harmony` option so that everything will work properly,
// in case you use anything that is behind the staging flag.
// Check https://nodejs.org/en/docs/es6/#which-features-are-behind-the-es_staging-flag
// to see which features require the flag.
var app = express();
var APP_PORT = process.env.PORT || 5000;
var APP_PATH = __dirname + "/public";
// We will need to split the output from morgan into lines to avoid trailing line feeds,
// https://github.com/expressjs/morgan/issues/70.
var log = log4js_1.getLogger();
var log4jsStream = split().on('data', function (line) {
log.debug(line);
});
app.use(morgan('tiny', { stream: log4jsStream }));
// `__dirname` in this case will be `./dist/` since we start the server from there.
app.use(express.static(APP_PATH));
app.all('/*', function (req, res) {
res.sendFile(APP_PATH + "/index.html");
});
var server = http_1.createServer(app);
server.listen(APP_PORT, function() {
// console.log(`Express server listening on port ${APP_PORT}`);
});
//# sourceMappingURL=server.js.map
最後,package.json
包含必要的DEPS。
所以我只是想知道,有沒有什麼辦法來部署一個應用程序來Azure和觸發npm install
並啓動Web服務器?
我可以看到,如果您通過Git來完成部署,捻角羚會做所有這一切對我來說。但在使用Wercker進行部署時,我不認爲這是我的選擇。此外,我編寫了一些打字稿文件在CI構建,我不希望這些版本控制,所以有一個混帳回購協議,我需要存儲所有編譯後的文件也不是一個選項。
我真的很感激如何處理一些這方面的投入。
第二個選項聽起來相當麻煩。我正在研究使用git併爲Kudu定製'deploy.sh'腳本,但是我嘗試失敗的大部分或者'npm install'超時,因爲安裝dev deps的時間太長,所以我可以構建它應用程序。 – Roland
也許擴大到更大的機器將有助於超時。它也應該是一次性成本,因爲第一次部署會填充依賴關係。 – theadriangreen