Reputation: 121
I am trying to set worker.bgw_restart_time = 1. This ensures that the background worker will restart in case of system crash.
But I want to restart my background worker if we restart postgres itself. Is there a way to do it?
Upvotes: 1
Views: 1352
Reputation: 36709
worker.bgw_restart_time = 1
means that the background worker process will be restarted automatically by the postmaster if the background worker process itself crashes. That way you can maintain a continuously running background process, even if it dies occasionally.
All background worker processes are automatically stopped if the PostgreSQL server is stopped altogether.
What happens on a restart depends on how the background worker is initialized. If it is loaded via shared_preload_libraries
, for example, it will be started automatically. In other cases it might be started much later when called upon.
There is no facility that "remembers" what background workers were running before a shutdown and starts them back up after a restart. You might have to implement something like that yourself specifically for what you are designing.
Upvotes: 4