fix: 60s lego timeout, stop on first failure, fall back to self-signed
This commit is contained in:
parent
1298589afa
commit
1705d1e32d
1 changed files with 6 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"crypto/rsa"
|
"crypto/rsa"
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
|
|
@ -176,12 +177,15 @@ func obtainCertsLego(domains []string, email, backupDir, legoDir, legoPath strin
|
||||||
"-d", domain,
|
"-d", domain,
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command(legoPath, args...)
|
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
cmd := exec.CommandContext(ctx, legoPath, args...)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
log.Printf(" [WARN] lego failed for %s: %v", domain, err)
|
log.Printf(" [WARN] lego failed for %s: %v", domain, err)
|
||||||
continue
|
// Don't try remaining domains — caller will generate self-signed fallbacks
|
||||||
|
return fmt.Errorf("lego failed for %s: %w", domain, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Small delay so port 80 is released between runs
|
// Small delay so port 80 is released between runs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue