Go to website
Back
Articles on:
Workers
Workers allow you to run code in a sandbox writen in SimpleScript.
Make a web request from a worker "s.http_request_get"
Workers are extremely flexible, and one thing they can do is load a webpage just like you expect with a CRON to do. This is useful if you need to do a web request so your site can do processing or update stuff. The reason we also print a message is to have something show up in the events history. You can also just echo the response from the page but if that page is large it can eat CPU time.
Some readers
Uptime checker with email notifications using API and workers
Workers are great, one thing you can do is check if a website is online using a ping test and if it is not online send a email to your account with only a few lines. Just replace where you see APIKEY in the url with your API key you can find under your account settings. As you can see we return the ping results to the page so it will show under the worker history, but we also if the ping failed (can't reach host) send a notification via the panel email system.
Few readers
Get alert if TLS/SSL/HTTPS certificate is not present or expired
We have updated our SimpleScript install on NodeHost and now you can take advantage of 2 new functions s.check_valid_ssl and s.check_expired_ssl to automatically get alerts when your SSL fails using workers. The script is simple and you just need to change the domain and enter in your API key to get alerts.
Few readers
Using functions in workers
Due to a recent SimpleScript update you can now use functions for looping and doing more advanced work in workers. To create a function you set it anywhere in your code like this example function. This sample function when you run it with f.amisandbox() will say true or false depending on if it's running in the sandbox. Here is a loop function example that will repeat the same
Few readers