Hey, can you help check if my discord application will stay up with the https server in this script?

javascript

#1
const Discord = require('discord.js');
const bot = new Discord.Client();
const Manager = new Discord.ShardingManager('./index.js');
Manager.spawn(2);

const http = require('http');
const express = require('express');
const app = express();

app.use(express.static('public'));

app.get("/", function(request, response) {
  response.sendFile(__dirname + '/views/index.html');
  console.log(Date.now() + " Ping Received");
});

const listener = app.listen(process.env.PORT, function() {
  setInterval(() => {
  http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);
})

I saw a post about Gareth helping someone merge their express.js file and node.js application. Will this work? The first part starts 2 shards of my discord bot (node.js application) and 2nd part is the original express.js file (that also throws the request in the form of a very bad website).


#2

Your express server is completely fine. However, if your Glitch project randomly goes offline it won’t be able to come back on again without it being pinged by you or an external server Note: projects are limited to 4000 requests per hour. I’d suggest using a service like Uptime Robot (uptimerobot.com) to ping your project URL every 5 minutes. You can also keep the embedded ping script.


#3

Okay thanks! :slight_smile: I just needed to confirm, I’m a amateur lol