0

I have a discord bot written in TS and running on node. When I deploy my code, the bot doesn't start but I can go to the Azure console and start via npm there. At this point, the bot is online and working as expected. However, after 60 seconds the console give an error and the bot is offline again. How can I add the node dist/app.js command as part of the deployment process so I don't have to start it from the console? below is my 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 on root directory

<?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>

Error from console file structure

  • You should put the contents of the dist folder under wwwroot. This way your program will be normal. – Jason Nov 10 '20 at 07:42
  • would doing so allow my application to run without any other changes? – KyleDimmadome Nov 10 '20 at 20:22
  • The contents of the dist folder should be placed in the wwwroot directory. – Jason Nov 11 '20 at 01:39
  • How does their location affect whether or not the code runs after deployment? I have updated the outDir in the tsconfig to have the files on the wwwroot level and updated all references but my previous issues still remain. – KyleDimmadome Nov 11 '20 at 02:06
  • Do you know what is in the dist folder? – Jason Nov 11 '20 at 02:32
  • In Azure, wwwroot stores the root directory of published files, not the root directory of the project. – Jason Nov 11 '20 at 02:33
  • Moved the contents of dist into wwwroot but the issue remains. – KyleDimmadome Nov 14 '20 at 23:35
  • https://stackoverflow.com/questions/63485396/unable-to-deploy-react-js-application-on-azure-app-service – Jason Nov 15 '20 at 08:39
  • I've looked through that thread and the one it sites as its solution but I fail to see what I can pull from that to address my situation. I don't have an index file and it's not a react application or on a Linux box. – KyleDimmadome Dec 08 '20 at 01:30

0 Answers0