I wonder why the service is shutting down after only a few minutes. The strange thing is that the database is empty next time I restart.
I have a free account. How do I configure to make it last longer between shutdowns and how do I manage to make it restart when there is a request to the API?
This is a log for less then 5 minutes:
INFO: 10.216.26.74:57370 - “GET / HTTP/1.1” 200 OK
Dec 15 08:18:45 AMINFO: 10.216.26.74:43856 - “GET / HTTP/1.1” 200 OK
Dec 15 08:18:50 AMINFO: 10.216.26.74:43862 - “GET / HTTP/1.1” 200 OK
Dec 15 08:18:52 AMINFO: Shutting down
Dec 15 08:18:52 AMINFO: Waiting for application shutdown.
Dec 15 08:18:52 AMINFO: Application shutdown complete.
Dec 15 08:18:52 AMINFO: Finished server process [40]
Dec 15 08:18:52 AMINFO: Waiting for application shutdown.
Dec 15 08:18:52 AMINFO: Application shutdown complete.
Dec 15 08:18:52 AMINFO: Finished server process [40]
Our free tier spins down after 15 minutes of inactivity, so the first request after the service is spun down make take a while, but subsequent requests should be faster. Is that what you’re observing? More info related to this here: https://render.com/docs/free
In the log, everything looks good at 08:18:50, but just 2 seconds later at 08:18:52, there’s a “Shutting down” entry. That’s really quick, and I’m not sure why.
Also, after the shutdown, the sqlite database ends up empty with no tables. I get an “Internal error” and in the log, there’s a message saying “(sqlite3.OperationalError) no such table: users”.
When I recreate all the tables, everything works fine again, but the problem happens again after the next shutdown. Any ideas why?
Your SQLite database is getting wiped out with every restart or deploy because we don’t persist file storage on the filesystem unless a disk is attached. To keep your files and new entries saved, you need to attach a disk to your service and save your sqlite database in it.