Skip to content

Conversation

@munozirianni1988
Copy link
Collaborator

Naming Rules

Name your PR like this: ISSUENUMBER-TITLE-YOURNAME

Description

Write a summary of your change. Explain why you have made it.

Related to

Make sure you include the issue number with a hash sign # so Github can link this PR to the right issue, like this:

Fixes #1

Checklist:

  • My code follows the style guidelines of this project
  • I have carefully reviewed my own code
  • I have commented my code
  • I have updated any documentation

Copy link
Collaborator

@mferryRV mferryRV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some thoughts on how you can simplify. Doing this with JS is likely overkill, as command line tools will not require any dependencies to accomplish the same task.

Make sure you run this workflow from a branch before you merge anything. Don't merge until you have it running successfully from the branch.

}
}

ping("starter-kit-al84.onrender.com");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an environment variable


on:
schedule:
- cron: "*/10 * * * *"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this frequent enough? Need to make sure you account for variations in cronjob startup time. If it shuts down after 15 min of inactivity then this 10 min timer should be fine. If it shuts down after 10 min of inactivity, you should shorten a bit e.g. 8 min

uses: actions/checkout@v2

- name: Run Ping Script
run: /usr/bin/node /server/serverPing.js
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to run npm i to install dependencies? Should these dependencies include the full project or just the two from pingServer?

@@ -0,0 +1,15 @@
const child_process = require("child_process"); //to run command-line tools
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to run JavaScript for this? Or could you just run ping $URL on the command line directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Matthew, thank you for all your comments. Really appreciate it! I think the only dependencies that should be included are the ones from pingServer. For running ping $URL on the command line directly, I wasn't sure how to do it, so I will have a read and change it. If you have any documentation recommendation that would be great.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing @munozirianni1988 - we're getting to the meat and potatoes of software engineering now!

I would look at curl for making HTTP requests from the command line, e.g.:

curl https://google.com

To make sure the response is good, you could look at HTTP status codes.

To see the requests that curl is making - or any app for that matter - you can use HTTPdump. It allows you to create a fake website or API endpoint and see what your code is sending on requests.

I'd also recommend looking at the monthly usage limits for Render to make sure that you can run the app all the time without running out of usage. You get 750 hours / month (31.25 days) but if those hours cover both the server and the database, you would only get 15.125 days for those two instances.

If you can't run it 24 hours a day, I'd recommend running your cronjob only during the 12 hours you think it will be most useful (e.g. 8am - 8pm every day, or 14 hours a day but it's off on Sundays). You could add additional optimisation by caching the database response in the API server, so we only hit the database once on startup (e.g. with node-fetch-cache). This would allow the database to be off most of the time, and the data only changes on deployment so it wouldn't get out-of-date.

Also make sure you look at the Github Actions free tier limits to make sure your cronjob will run all month. It may also help you ask questions like "Is it better to have a new job every 10 minutes or a 4-hour job that does something every 10 minutes?"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wow! Like we say in Cuba: el mango del arroz con mango! hahaha. I will dive into all this information as soon as I get home today. I wouldn't have a clue as to where to start looking/researching for all this, and all I was finding were very long complicated solutions. Thank you very much @mferryRV !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show rhythms on map

3 participants