How it works
The HTTP-Listener below opens a Port. So if a user send a HTTP-Request to your Page, this Listener will answer.
A normal free Glich.com Project shutdown automatically when 5 minutes no Request will send to the App.
Method 1: Go to this page every 5 minutest with your browser, to keep your project alive.
But, we all know, it's not a very good method.
So, this tool up will send automatic using crontab
every 5 Minutes a HTTP-Request to your Listner.
So your server needs just every 5 Minutes a very small progess, and your NodeJS-Application runs 24/7 with the Performance from the Glitch-Servers.
It's just a small server needed, if you don't have a server, i suggest a Raspberry Pi or ask a friend! :D
I will update this article, if i find better soulutions. But the old, works too.
Setup
HTTP-Listener
: Set to your NodeJS Applicaion
Just add to your
server.js
this code. No config is here needed.
let express = require("express"),
http = require('http'),
app = express();
app.use(express.static("public"));
app.get("/", function(request, response) {
response.sendStatus(200); // Status: OK
});
let listener = app.listen(process.env.PORT, function() {
console.log("Your app is listening on port " + listener.address().port);
});
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);
Automatic HTTP-Request
: Run on your Server
Run this commands in the Bash. But: Change in the First Line the
my-example-nodejs
to your Project Name.
PROJECT=my-example-nodejs
echo "5 * * * * curl https://$PROJECT.glitch.me/" > /etc/cron.d/glitch-up
service restart cron
Top comments (1)
they patched it