Run the certbot.
(&self)
| 148 | |
| 149 | /// Run the certbot. |
| 150 | pub async fn run(&self) { |
| 151 | loop { |
| 152 | match self.renew(false).await { |
| 153 | Ok(renewed) => { |
| 154 | if !renewed { |
| 155 | continue; |
| 156 | } |
| 157 | if let Some(hook) = &self.config.renewed_hook { |
| 158 | info!("running renewed hook"); |
| 159 | let result = std::process::Command::new("/bin/sh") |
| 160 | .arg("-c") |
| 161 | .arg(hook) |
| 162 | .status(); |
| 163 | match result { |
| 164 | Ok(status) => { |
| 165 | if !status.success() { |
| 166 | error!("renewed hook failed with status: {status}"); |
| 167 | } |
| 168 | } |
| 169 | Err(err) => { |
| 170 | error!("failed to run renewed hook: {err:?}"); |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | Err(e) => { |
| 176 | error!("failed to run certbot: {e:?}"); |
| 177 | } |
| 178 | } |
| 179 | sleep(self.config.renew_interval).await; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | /// Run the certbot once. |
| 184 | pub async fn renew(&self, force: bool) -> Result<bool> { |