node.js - 如何在 Azure 的 Node 上启动 Discord 机器人
问题描述
我有一个用 TS 编写并在节点上运行的不和谐机器人。当我部署我的代码时,机器人不会启动,但我可以转到 Azure 控制台并通过那里的 npm 启动。此时,机器人已在线并按预期工作。但是,60 秒后,控制台给出错误,机器人再次脱机。如何将 node dist/app.js 命令添加为部署过程的一部分,这样我就不必从控制台启动它?下面是我的 package.json
{
"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>
解决方案
推荐阅读
- python - 一个列表如何与另一个列表进行比较?
- haskell - 为什么使用 fold 来生成指数增长的无限列表溢出?
- php - 如何在 Laravel 7.8.1 上安装 laravel/ui 包
- javascript - if 语句针对本地存储的 JSON 对象中的未定义参数
- python - Python:如何在句子的单词列表中找到一个字母并以原始大小写(大写/小写)返回这些单词
- java - Spring:请求范围的 bean 如何在异步方法调用中表现
- python - 如何在已经训练好的 xgboost 模型上使用 CalibratedClassifierCV?
- html - html和css中的位置问题
- javascript - 如何将两个不同的值存储在同一输入的两个不同变量中?
- mysql - Zabbix - 缓冲池利用率太低