Sleeping mode with stack Strapi & Postgredatabase
aurelien-f
HOBBYOP

2 years ago

Stacks :
Strapi
Database Postgre

11 Replies

aurelien-f
HOBBYOP

2 years ago

Hello, I have a problem, my application is supposed to be in sleeping mode but when I look at the usage, I have continuous memory while nobody is using the application. Can anyone help me?

Attachments


2 years ago

The metrics get frozen in place when the app goes to sleep. It's extremely misleading but as long as your service says it's sleeping there is nothing to worry about.


aurelien-f
HOBBYOP

2 years ago

hello, how can i see if my service sleeping please ? my Memory grow up or i didnt use my service. Maybe the sleeping mode are broken.


2 years ago

Your service will very clearly be marked as sleeping, there is no possible way to miss it. If it doesn't say it's sleeping, then it's not sleeping.


aurelien-f
HOBBYOP

2 years ago

Ok thanks, i've Network activity and i don't know with… do you have any idea please ?


2 years ago

Are you having Strapi connect to the database via the public network? if so Strapi would never be able to sleep because it would be holding an outbound connection open, you would want to connect to the database privately, you can see how the Strapi template archives that here -

This config file is used when running on Railway -

https://github.com/railwayapp-templates/strapi/blob/main/config/database.js

This config file is used when running locally -

https://github.com/railwayapp-templates/strapi/blob/main/config/env/development/database.js

You would need to have both of those environment variables on your Strapi service.


aurelien-f
HOBBYOP

2 years ago

Thanks for the help.

I've this code on my database.js :

return {
connection: {
client,
…connections[client],
acquireConnectionTimeout: env.int('DATABASECONNECTIONTIMEOUT', 60000),
},
};

i'll check your code :)


aurelien-f
HOBBYOP

2 years ago

pool: {
min: env.int("DATABASEPOOLMIN", 2),
max: env.int("DATABASEPOOLMAX", 10),
},


aurelien-f
HOBBYOP

2 years ago

Great, it's ok for my database thanks. My database sleeping correctly but my container with Strapi didn't sleep


aurelien-f
HOBBYOP

2 years ago

It's ok pour both now !!! Thanks for help man ! Your great !


2 years ago

You can't have your database sleep as it will never wake up via the private network, please only enable app sleeping on Strapi itself.


Loading...