Common daemonization option
| 263 | |
| 264 | |
| 265 | class DaemonOption(CeleryOption): |
| 266 | """Common daemonization option""" |
| 267 | |
| 268 | def __init__(self, *args, **kwargs): |
| 269 | super().__init__(args, |
| 270 | help_group=kwargs.pop("help_group", "Daemonization Options"), |
| 271 | callback=kwargs.pop("callback", self.daemon_setting), |
| 272 | **kwargs) |
| 273 | |
| 274 | def daemon_setting(self, ctx: Context, opt: CeleryOption, value: Any) -> Any: |
| 275 | """ |
| 276 | Try to fetch daemonization option from applications settings. |
| 277 | Use the daemon command name as prefix (eg. `worker` -> `worker_pidfile`) |
| 278 | """ |
| 279 | return value or getattr(ctx.obj.app.conf, f"{ctx.command.name}_{self.name}", None) |
| 280 | |
| 281 | |
| 282 | class CeleryDaemonCommand(CeleryCommand): |