Stuck in building and deploying
My project is stuck in building and deploying, because my index.js has a setTimeout (in scheduleRefresh) that repeats once per day. How do I tell the build function to not get stuck here?
7 Replies
I'd recommend perhaps running a different build command that doesn't invoke
index.js
, or maybe a separate file to run that only builds and then exits?
Pages also sets some environment variables like CI
to true
, that you could check and not run any long-running tasks: https://cfdata.lol/products/pages/How would I go about calling this seperate file after building is completed?
I'm not sure what you mean? Pages isn't a server for serving long-running content. You need to build, output files, and then exit, which Pages will then serve.
I've tried putting the relevant call back in app.listen but that didnt help
You can't do things like run express apps, or long-running servers.
?pages-webserver
Cloudflare Pages is for static content (HTML, CSS, JS, images and other such files). It will not run a webserver such as Express, Koa or the likes. If you're using those to serve static content then you can just remove that part and use Pages! If you're doing more dynamic content you can use Functions (https://developers.cloudflare.com/pages/platform/functions). It will run code on request (so still not a webserver in the conventional sense). This would allow for more dynamic content though especially with KV (Key Value storage) and Durable Objects (transactional data storage). Functions are natively integrated with Pages so are super easy to get up and running along your website. Otherwise, a good old VPS or dedicated server from one of the many hosts out there is for you.
Got it
Ty