Node.js 如何在Azure中的节点上启动Discord bot
我有一个用TS编写并在节点上运行的discord bot。当我部署代码时,bot不会启动,但我可以转到Azure控制台并通过那里的npm启动。此时,bot已联机并按预期工作。但是,60秒后,控制台出现错误,bot再次脱机。如何将node dist/app.js命令添加为部署过程的一部分,以便不必从控制台启动它?下面是我的package.jsonNode.js 如何在Azure中的节点上启动Discord bot,node.js,typescript,azure,Node.js,Typescript,Azure,我有一个用TS编写并在节点上运行的discord bot。当我部署代码时,bot不会启动,但我可以转到Azure控制台并通过那里的npm启动。此时,bot已联机并按预期工作。但是,60秒后,控制台出现错误,bot再次脱机。如何将node dist/app.js命令添加为部署过程的一部分,以便不必从控制台启动它?下面是我的package.json { "name": "d-app", "version": "1.0.0&
{
"name": "d-app",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\"",
"start": "node dist/app.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@types/node": "^14.0.23",
"discord-akairo": "github:1Computer1/discord-akairo",
"discord.js": "github:discordjs/discord.js",
"i": "^0.3.6",
"ms": "^2.1.2",
"sqlite3": "^5.0.0",
"twilio": "^3.51.0",
"typeorm": "^0.2.25"
}
}
根目录上的web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<webSocket enabled="false" />
<handlers>
<!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="dist/app.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^dist/app.js\/debug[\/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="dist/app.js"/>
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<httpErrors existingResponse="PassThrough" />
<iisnode watchedFiles="web.config;*.js"/>
</system.webServer>
</configuration>
您应该将dist文件夹的内容放在wwwroot下。这样,您的程序将正常运行。这样做是否允许我的应用程序在没有任何其他更改的情况下运行?dist文件夹的内容应放在wwwroot目录中。它们的位置如何影响部署后代码是否运行?我已经更新了tsconfig中的outDir,使文件处于wwwroot级别,并更新了所有引用,但我以前的问题仍然存在。你知道dist文件夹中有什么吗?