Я создал очень простой диск-бот и пытаюсь разместить его на azure. Когда я запускаю его локально, он работает нормально. Когда я развертываю его, он работает некоторое время, а затем падает и перезапускается.
я получаю
2020-03-23T21:41:50.738748919Z _____
2020-03-23T21:41:50.738817719Z / _ \ __________ _________ ____
2020-03-23T21:41:50.738824419Z / /_\ \___ / | \_ __ \_/ __ \
2020-03-23T21:41:50.738828419Z / | \/ /| | /| | \/\ ___/
2020-03-23T21:41:50.738832119Z \____|__ /_____ \____/ |__| \___ >
2020-03-23T21:41:50.738836019Z \/ \/ \/
2020-03-23T21:41:50.738839619Z A P P S E R V I C E O N L I N U X
2020-03-23T21:41:50.738843319Z
2020-03-23T21:41:50.738846719Z Documentation: http://aka.ms/webapp-linux
2020-03-23T21:41:50.738850119Z NodeJS quickstart: https://aka.ms/node-qs
2020-03-23T21:41:50.738853619Z NodeJS Version : v12.13.0
2020-03-23T21:41:50.738857019Z Note: Any data outside '/home' is not persisted
2020-03-23T21:41:50.738873019Z
2020-03-23T21:41:51.030040223Z Oryx Version: 0.2.20191105.2, Commit: 67e159d71419415435cb5d10c05a0f0758ee8809, ReleaseTagName: 20191105.2
2020-03-23T21:41:51.030978923Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2020-03-23T21:41:51.038540817Z Build Operation ID: |Nl1fjNBjXG0=.86fc023f_
2020-03-23T21:41:52.164947961Z Environment Variables for Application Insight's Codeless Configuration exists..
2020-03-23T21:41:52.165846260Z Writing output script to '/home/site/wwwroot/oryx-appinsightsloader.js'
2020-03-23T21:41:52.523126320Z Writing output script to '/opt/startup/startup.sh'
2020-03-23T21:41:52.729416182Z Running #!/bin/sh
2020-03-23T21:41:52.729893482Z
2020-03-23T21:41:52.729904682Z # Enter the source directory to make sure the script runs where the user expects
2020-03-23T21:41:52.729909382Z cd "/home/site/wwwroot"
2020-03-23T21:41:52.729913282Z
2020-03-23T21:41:52.729916782Z export NODE_PATH=$(npm root --quiet -g):$NODE_PATH
2020-03-23T21:41:52.729920482Z if [ -z "$PORT" ]; then
2020-03-23T21:41:52.730906381Z export PORT=8080
2020-03-23T21:41:52.730917481Z fi
2020-03-23T21:41:52.730921481Z
2020-03-23T21:41:52.730925081Z echo Found tar.gz based node_modules.
2020-03-23T21:41:52.730928781Z extractionCommand="tar -xzf node_modules.tar.gz -C /node_modules"
2020-03-23T21:41:52.731720380Z echo "Removing existing modules directory from root..."
2020-03-23T21:41:52.731731380Z rm -fr /node_modules
2020-03-23T21:41:52.731735380Z mkdir -p /node_modules
2020-03-23T21:41:52.731738880Z echo Extracting modules...
2020-03-23T21:41:52.737901476Z $extractionCommand
2020-03-23T21:41:52.737914876Z export NODE_PATH="/node_modules":$NODE_PATH
2020-03-23T21:41:52.737919576Z export PATH=/node_modules/.bin:$PATH
2020-03-23T21:41:52.737931076Z if [ -d node_modules ] || [ -L node_modules ]; then
2020-03-23T21:41:52.737935076Z mv -f node_modules _del_node_modules || true
2020-03-23T21:41:52.737938676Z fi
2020-03-23T21:41:52.738335276Z
2020-03-23T21:41:52.738348276Z if [ -d /node_modules ]; then
2020-03-23T21:41:52.738352876Z ln -s /node_modules ./node_modules
2020-03-23T21:41:52.738356776Z fi
2020-03-23T21:41:52.738635876Z
2020-03-23T21:41:52.738700276Z echo "Done."
2020-03-23T21:41:52.738743776Z export NODE_OPTIONS='--require ./oryx-appinsightsloader.js ' $NODE_OPTIONS
2020-03-23T21:41:52.738885175Z npm start
2020-03-23T21:41:53.504769761Z Found tar.gz based node_modules.
2020-03-23T21:41:53.505139861Z Removing existing modules directory from root...
2020-03-23T21:41:53.515730254Z Extracting modules...
2020-03-23T21:41:53.800945462Z Done.
2020-03-23T21:41:55.412480180Z
2020-03-23T21:41:55.412504880Z > my-bot@1.0.0 start /home/site/wwwroot
2020-03-23T21:41:55.412521380Z > node stonksbot.js
2020-03-23T21:41:55.412525880Z
2020-03-23T21:41:56.623960067Z Logged in as Mr.Stonks#0654!
2020-03-23 21:45:42.618 ERROR - Container stonksbot1_0_0cecfd85 for site stonksbot1 did not start within expected time limit. Elapsed time = 231.774951 sec
2020-03-23 21:45:42.620 ERROR - Container stonksbot1_0_0cecfd85 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging.
2020-03-23 21:45:42.642 INFO - Stoping site stonksbot1 because it failed during startup.
Я не настроил docker, так что я предполагаю azure делает это для меня.
мой пакет выглядит так
{
"name": "my-bot",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node stonksbot.js"
},
"dependencies": {
"discord.js": "^11.6.3"
},
"devDependencies": {}
}
, а мой код выглядит следующим образом.
const Discord = require('discord.js');
const client = new Discord.Client();
client.login(my token);
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {
// do something
});
Кто-нибудь знает решение?