Google Cloud Worker #968
Replies: 7 comments 17 replies
-
@gabriele this is the Asset Storage strategy I use, and works for me https://github.com/martijnvdbrug/pinelab-vendure-plugins/blob/master/packages/vendure-plugin-google-storage-assets/src/google-storage-strategy.ts |
Beta Was this translation helpful? Give feedback.
-
A bit outdated, but nevertheless https://martijn-brug.medium.com/vendure-ecommerce-on-google-cloud-run-225b26c8133a |
Beta Was this translation helpful? Give feedback.
-
Investigating Task Queue in Cloud Run , as it pushes messages from the queue to an endpoint, everything works within a request context. I have to investigate a bit further on how this fits in the current jobqueuestrategy though |
Beta Was this translation helpful? Give feedback.
-
@martijnvdbrug thanks a lot (!!!) for sharing your gcp-asset-storage plugin, with it now that part is working, so there was some issue in my implementation of the plugin @michaelbromley the plugin is correctly sending jobs messages to the PubSub topic, but the subscription part (i.e. receiving the message and performing the job) is not happening at all. I think I have to manually set a push endpoint on the subscription configuration (I didn't because I thought it used a pull approach). Am I right? In this case, which endpoint should I set to let Vendure actually receive messages? |
Beta Was this translation helpful? Give feedback.
-
Good morning, I have now tested my implementation, and it is actually working, at least for apply-collection-filters and search index job queues (still have to test email jobs). Thanks a lot for all your hints!
The only thing that seems not to work is that jobs, while actually being executed (tested both by checking worker debug logs and actual db modifications) are not listed at all in the admin area. @michaelbromley any idea of why Jobs, while being present in the db, are not retrieved at all? Please find here the code of my Cloud Run VendureServer service, implemented with Pulumi infrastructure as code: Of course I will test this further before moving my production store to GCP. |
Beta Was this translation helpful? Give feedback.
-
A little update:
Cloud Tasks plugin: https://www.npmjs.com/package/vendure-plugin-google-cloud-tasks This will run on Google Cloud Run/appengine, because jobs are pushed to an endpoint, processing jobs within a request context. Keep in mind that the request timeout for HTTP targets for Google Tasks is 30 minutes (should be enough per job, in most cases) |
Beta Was this translation helpful? Give feedback.
-
ℹ️ Workaround untill the worker supports incoming HTTP calls: This version supports Google Cloud tasks with a seperate Vendure worker instance: https://www.npmjs.com/package/vendure-plugin-google-cloud-tasks/v/1.2.0 ** Please note that the current worker does not listen for incoming HTTP calls, so you will need to start the whole Vendure app, not just the worker **
bootstrap(config)
.then(async (app) => {
await app.get(JobQueueService).start();
Logger.info(`\x1b[46mUsing database ${process.env.DATABASE_NAME} \x1b[0m`);
})
.catch((err) => {
Logger.error(err);
});
|
Beta Was this translation helpful? Give feedback.
-
This discussion started on slack, but moved to GH discussion to preserve this info :)
Martijn 3 days ago
Hi all. I'm trying to implement the worker using Google Cloud TaskQueue. It works like this: Put a message in the queue, TaskQueue will push the message to a given endpoint. How would I accept tasks/jobs coming in from an endpoint? It looks like the current JobQueueStrategey only supports polling (by starting/listening on a queue)
Michael Bromley 3 days ago
Did you already take a look at this: https://github.com/vendure-ecommerce/vendure/blob/master/packages/job-queue-plugin/src/pub-sub/pub-sub-job-queue-strategy.ts ?
The JobQueueStrategy is not restricted to polling - the above example is push (subscription) based.
Martijn 1 day ago
Ibthink this example uses pull subscriptions, not entirely sure. I will look into it 👍
Gabriele 1 day ago
Hi @martijn, I have spent a lot of time trying to deploy Vendure to Google Cloud, using Cloud Run for Server & Worker. It doesn’t work: jobs are hanging indefinitely and the same for assets upload (which I have adapted for Google Cloud Storage through a plugin). Even disabling Cloud Run’s downscale to zero (i.e. setting minimum container scale to 1) doesn’t change this. Maybe you have had similar experience? I was thinking of switching to Kubernetes, but deploying the server to Cloud Run and implementing an alternative job queue implementation seems interesting. Though I am afraid server implementation has problems too, because asset upload is performed by the server, as Michael confirmed, and it doesn’t work either.
If you can share more on your experience with Google Cloud it could be beneficial for me! Thanks!!
Gabriele 1 day ago
I also tag @s3m3n as I found some of his previous messages regarding Google Cloud, maybe he has some more experience to share on this. Thanks!
Martijn 3 hours ago
@gabriele Thanks for your response! I did get the asset upload to work with Cloud Run, I can share a code sample with you if needed. I am having the same issues with the worker on Cloud Run: everything in Cloud Run should be handled within a request context, everything outside of the request context is not guaranteed to finish, even with a min instance of 1.
I have the feeling that pull subscriptions don't entirely work because of this, so I am looking into Task Queue.
Michael Bromley 2 hours ago
Guys this knowledge is very valuable. It would be amazing if someone could write up their findings somewhere public e.g a gist GH discussion thread and I can later incorporate it into the docs. Does not have to be really polished, just the key points that will save other devs lots of time and research. (edited)
discodancer 1 hour ago
You can try this tool - it's in beta still, but you might get access: https://docs.github.com/en/discussions
Gabriele 6 minutes ago
@martijn thanks, I am trying to move to Google Kubernetes Engine, but a code sample for asset management will be useful, I have implemented a plugin and it reads correctly, but upload methods never get called! @michael Bromley as soon as I have a Google cloud instance working I want to write a blog post about it and also share some code. I am also using Pulumi infrastructure as code framework, which is quite interesting
Beta Was this translation helpful? Give feedback.
All reactions