I'm planning on using WordPress as a headless CMS for a project and using the REST API to retrieve content. I have a few cron tasks that need to run fairly regularly within WordPress and I want to know if API calls are enough to trigger them, or if I'll need to add that functionality myself.
Edit: when I say cron I mean wp_cron
Tasks scheduled through WP_Cron are evaluated to determine if the task should be run each time the init hook is executed [1]. The init hook should be fired on every request for a URL that WordPress is configured to respond to, including REST API calls (although I can't find a definitive source to cite for this).
As such, calls to WordPress REST API should indeed trigger any code scheduled via WP_Cron and which is due to be executed per its configuration.
Related
I have created a data pipeline in Airflow which helps to update the tickets in Freshdesk whenever some values are change in the tickets during business hours. My logic for updatding the ticket is working fine, but I want to make the trigger the dags whenever a event is occured in Freshdesk interface so that I don't need to manually trigger the dags.
There are automation rules in FreshDesk which provides the external webhook in https://companyname.freshdesk.com/api/v2/tickets/{{ticket.id}} where {ticket.id} is essentail to know the id for which the tickets are updated from the data pipeline.
I need to know how to connect the external trigger such as webhook so that we can trigger the data-pipeline automatically in Airflow.
My Airflow Version 1.10
Airflow doesn't have a mechanism that allows triggering DAG based on webhooks from other services.
That use case might be covered by AIP-35 Add Signal Based Scheduling To Airflow but this is currently a draft idea of enhancement to Airflow.
To achieve your use case with current functionality you will need to other application/service to handle the webhook fired by Freshdesk and triggering a new DAG run in Airflow with RestAPI Trigger new DAG run endpoint
You need to be aware of frequency. If the frequency of creating new DAG runs is too high you should consider switching to a batch solution (which Airflow is more suitable for)
I am not sure about Freshdesk, but according to this it sounds as if you're able to hit an external API with its automation mechanism.
If that's the case, then I think this is what you're looking for. That's the documentation for the REST API reference of Apache Airflow.
Airflow allows you to manage it via web API, but you first need to enable it in the configuration. You should set the following configuration to use at least basic auth.
Keep in mind that back then that was an experimental API and newer versions changed the URL schema and the API a bit. It's much more complete nowadays.
I want to respond to Firebase events to generate (keep updated) to generate HTML pages and put them to Firebase Hosting so that they can be immediately available for use. I have it working except for the part about uploading the resulting HTML to Firebase hosting. It seems like I cannot do it this way but I want to so that all the pages are pre-rendered and ready to load fast.
I have cloud functions connected to hosting but that is the same old way of fetching from the database during a request cycle which I wanted to avoid.
On this page it says "Prerender your single-page apps to improve SEO." and thats what I want. Is it possible? How to store the pre-rendered pages from a HTTP function?
The "Prerender your single-page apps to improve SEO." talked about on that page is prerender in the cloud before serving the content to the requesting party. It is not generate static files when data updates before a request is even made.Generally the prerendering with appropriate caching headers is enough for most use-cases.
If you really want to pregenerate all the pages whenever data changes, you could do that but that'll be more complicated. There are some good articles and guides about deploying to Firebase Hosting after continuous integration finishes. The general idea holds true for what it sounds like you want except what triggers the build/deploy is data driven rather than code change.
The way to pre-render HTML so that metadata such as JSON-LD is available to search engines and opengraph is available to social media platforms for rich cards in shared links is to use Cloud Functions. You basically run Express/Pug (previously Jade) in your cloud function(s) to respond with HTML after whatever database/datastore lookups have completed. I've implemented this and it works great.
Call functions via HTTP requests provides some direction. You basically add some forwarding info to customize your hosting. This will direct HTTP calls over to your Express server running in Cloud Functions. Check the firebase functions github repo for sample code.
I have so far been very impressed with the firebase platform for hosting a client-side single page app and for data storage. However, I have one component that I don't know where to host...
I want to have a background process that aperiodically updates the database. The nature of when an update is needed is based on an external source and, although the general timeframe of when updates are available is known, the exact timing is not. My thinking was to have a background task running that has some smarts to determine when an update is needed, and then trigger an update at that time.
I don't know where I would host something like this. I considered running it in a loop in a firebase function, but due to pricing model being based on time, that would get very expensive, and functions are not suited for daemon-type processes. The actual "database update" would be suitable for a function, but not the triggering logic. Also, I have seen functions-cron which does offload the triggering logic, but since my updates are not truly periodic, it doesn't seem exactly appropriate. I haven't looked too much into AppEngine and how that relates to the firebase platform...so basically my question:
What are the options for "reasonably-priced" hosting an always-running background task?
Google App Engine - Standard is something you want to look at more. It is reasonably priced since what you are doing will likely fit into GAE-Std's free daily quota. In GAE-Std, you create a scheduled cron job: GAE will call you task as if it was an incoming web request.
See Firebase doc for integrating with GAE
See GAE doc for cron jobs
In a Website GTM implementation , you have the possibility to create your own custom tags using javascript, so it's easy to set up webservice calls to your own system etc by just using the GTM interface.
Now for a Firebase - GTM implemented app, are there any possibilities like this?
I saw the functioncall option, but if I get it correct, this means you need to program some methods/functions inside your app and you can call them using GTM and there's also the option to pass some params. This is not quite the same as the website-gtm tags, which we can create on the fly in GTM.
Is there any other way , without the need to redeploy your app ?
Yeah, since we cannot inject code into an app using GTM there are no custom tags.
True, there is a Firebase function. Another option which has been used for a while in GTM SDK is an image tag.
It lets you execute server-side code on your server or use azure function as well as firebase function
I believe the advantage of GTM with mobile apps is that you can manage existing events and parameters by enabling or disabling them. When you release a version of your app that is logging a certain way you will not be able to change that and any users that have not updated to your new version will continue to log the same information.
Example:
MyApp v1.0.0
MyEvent
- my_param_id
- my_param_name
- my_param_etc
MyApp v1.0.1
MyEvent
- my_param_id (this is now the name)
- my_param_etc
Without GTM users with 1.0.0 will still be logging in the same way it was set up at the time it was released. With GTM you will be able to filter out those events with the "trigger" to not allow those events to get logged.
This has been a while, in the meantime I have been searching myself.
It seems like the best option to manipulate stuff and execute custom tags are the Cloud Functions in Firebase that can be triggered by Firebase Events.
I'm building a project to send messages to users. The client wants a way to schedule these messages to be sent out at a certain time, for example, he creates the message at 2am but wants it to be sent out at 10am without his intervention, where do I begin with this sort of thing? I'm using ASP.NET MVC3, any help is appreciated.
Update
Darin has suggested Quartz.net, I've finally gotten around to attempting to set it up. But I'm not really understanding how to implement it with my web app.
I'm assuming I should be able to make an httprequest from my service to an action on my webapp, triggered by quartz. But I'm not sure how to communicate between the webapp and this service, such as sending instructions to the quartz server.
So far, I've created a windows service, set up the installers, and added the Quartz.net server 2010 solution to my service project, am I on the right track?
Using a managed Windows Service with Quartz.NET or a console application which you would schedule with the Windows task scheduler seems like a good approaches to achieve that.
Welp, there are scheduled tasks... either make a localhost request at a specific time, or write an executable/service to be called.
A possible alternative if you can't use scheduled tasks (but may be dependent upon the website being available to the Internet) is to make a remote request-maker program or use a website monitoring service. Have either of those make a request to a particular page/querystring on your site periodically. Then, make the web application perform a particular task (send an email) whenever that resource is requested.
A few free monitoring services are limited to one request every hour or half-hour, or you can pay to have it checked more often. The resource's code could be made to record the message-sending event, (thus making them only get sent once, regardless of how often the request is made)