Jump to content

Requesting external cron job setup for Ghost CMS


Seekier

Recommended Posts

Hi, thank you for the good job on heliohost.

Pls I would like the admin to help me set up an external cron job for my Ghost CMS website. The one I have is from https://cron-job.org/en/ and whenever I turned it on the red and blue bar on my account gragh climb between 90 to 100 in an hour which possible always leads to suspension.

 

Server: Tommy

Website: fzmedia.cf

 

For fear of being suspended, I have redirected my website to blogger pending when my request is met.

 

Thanks in advance

Link to comment
Share on other sites

An external cron that we set up is going to cause just as much load as an external cron from any other site.

 

The way passenger works is this. Node applications take a lot of memory when they're running, but they only need to run when someone is actually looking at the website. The first time you request a node page it takes a second or two to load, and once the node app is running it responds quickly. After 5 minutes or so of no page hits passenger wisely unloads your node app from memory which helps keep your account and the whole server's load low. This is by design.

 

The problem with ghost is it stupidly says 503 when it's loading instead of just taking a second longer to load like a normal node app and then showing the home page. People have asked ghost to change this behavior and they have stupidly refused. Obviously you've discovered that to avoid that 503 error you just keep ghost from unloading from memory by setting up a cron or site monitor to ping your website every once in a while. This is why you're getting suspended. Your ghost page is never unloading from memory. Your sitemonitor or cron or whatever is causing so much load that you're getting suspended. It doesn't matter if the page request comes from our servers or someone else's server. The solution to your high load is to just let passenger do it's thing and unload your ghost when it's not being viewed.

 

The other option is of course you could also get a vps and then your ghost app could run constantly and you wouldn't even need a cron or sitemonitor to keep the 503's away. https://www.heliohost.org/vps/

 

Another option is you could edit the ghost code to not display the 503 error somehow.

Link to comment
Share on other sites

The problem with ghost is it stupidly says 503 when it's loading instead of just taking a second longer to load like a normal node app and then showing the home page. People have asked ghost to change this behavior and they have stupidly refused. Obviously you've discovered that to avoid that 503 error you just keep ghost from unloading from memory by setting up a cron or site monitor to ping your website every once in a while.

I just opened my ghost install in a browser https://krydos.heliohost.org/ghost/ and it took like 15 seconds, but it didn't show a 503. Maybe they changed the behavior in the newer version that I installed?

 

EDIT:

 

Nevermind, I guess it was a fluke. I killed the ghost process and tried loading it again and it gave the 503 this time.

Edited by Krydos
Link to comment
Share on other sites

I had another idea. You could make a loading page that would load instantly, and then check if ghost is running. Then if ghost is running redirect automatically. If ghost isn't running or gives a 503 error it just waits a second and tries again until ghost is functional, and then it redirects. Here's a quick example:

<?php

$url = "https://ghost.krydos.heliohost.org/";
$msg = "Loading ghost...";

if ($_GET['retry'] == "") {
  echo "$msg<meta http-equiv='refresh' content='0;url=?retry=yes' />";
  exit;
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 10000);

$f = curl_exec($ch);
$h = curl_getinfo($ch);
curl_close($ch);

$status = $h['http_code'];

if ($status == "200") {
  header("Location: $url");
  exit;
} else {
  echo "$msg<meta http-equiv='refresh' content='1;url=?retry=yes' />";
  exit;
}
You can test it out at https://krydos.heliohost.org/ghost/ which redirects to ghost at ghost.krydos.heliohost.org

 

Obviously if you're using this code on a production website you'd want to style it and make it a little prettier... haha. Also meta refreshes are kind of a dirty hack and are frowned upon and you shouldn't use them, but they still work. A better page refresh option would be javascript. Also this page the way it's written will just try again and again and again over and over forever, which could cause load problems if ghost wouldn't start and someone left this page open refreshing over and over all day. So it would be wise to implement a counter and after the page refreshes like 5 times, just give up and display an error message. Like I said, it's a quick example.

Edited by Krydos
Link to comment
Share on other sites

Thanks for the quick response.

 

Obviously Ghost is as terrible as WordPress in terms of loads only it is not prune to hacking like WordPress.

I will try the code above and set the number of try/refresh to 3, If unable to process request return back to it favorite 503 error.

 

I would have love to try the JavaScript refresh option but I know nothing about java

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...