Skip to content

Commit 2c41411

Browse files
Copilotnomeguy
andcommitted
Refactor auto-recovery: move to util package, always enable, remove tests
Co-authored-by: nomeguy <85475922+nomeguy@users.noreply.github.com>
1 parent 4015ae9 commit 2c41411

File tree

7 files changed

+10
-354
lines changed

7 files changed

+10
-354
lines changed

README.md

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,12 @@ After creating an organization and an application for CasWAF in a Casdoor, you n
9090
- Configure and run CasWAF by yourself. If you want to learn more about caswaf.
9191
- Open browser: http://localhost:16001/
9292

93-
#### Enable Auto-Recovery (Recommended for Production)
94-
95-
CasWAF includes a built-in auto-recovery mechanism that automatically restarts the process if it crashes. This is enabled by default but can be configured in `conf/app.conf`:
96-
97-
```ini
98-
autoRecoveryEnabled = true
99-
```
100-
101-
This feature:
93+
CasWAF includes a built-in auto-recovery mechanism that automatically restarts the process if it crashes. This feature is always enabled and:
10294
- Automatically restarts CasWAF if it crashes
103-
- Prevents restart loops with smart restart limits
95+
- Prevents restart loops with smart restart limits (max 5 restarts in 5 minutes)
10496
- Works cross-platform (Windows, Linux, macOS)
10597
- Uses pure Go with no external dependencies
10698

107-
For more details, see [supervisor/README.md](supervisor/README.md).
108-
109-
**Note**: If using external process managers (systemd, Docker, Kubernetes), set `autoRecoveryEnabled = false` to avoid conflicts.
110-
11199
### Optional configuration
112100

113101
#### Setup your WAF to enable some third-party login platform

conf/app.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,3 @@ language = "en"
3232
appMap =
3333
acmeEmail = ""
3434
acmePrivateKey = ""
35-
autoRecoveryEnabled = true

main.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,28 @@ import (
2222
"github.com/beego/beego/plugins/cors"
2323
_ "github.com/beego/beego/session/redis"
2424
"github.com/casbin/caswaf/casdoor"
25-
"github.com/casbin/caswaf/conf"
2625
"github.com/casbin/caswaf/ip"
2726
"github.com/casbin/caswaf/object"
2827
"github.com/casbin/caswaf/proxy"
2928
"github.com/casbin/caswaf/routers"
3029
"github.com/casbin/caswaf/run"
3130
"github.com/casbin/caswaf/service"
32-
"github.com/casbin/caswaf/supervisor"
3331
"github.com/casbin/caswaf/util"
3432
)
3533

3634
func main() {
37-
// Check if auto-recovery is enabled and we're not already supervised
38-
if conf.GetConfigBool("autoRecoveryEnabled") && !supervisor.IsSupervisedProcess() {
35+
// Auto-recovery is always enabled - check if we're not already supervised
36+
if !util.IsSupervisedProcess() {
3937
// Run as supervisor
40-
err := supervisor.Run()
38+
err := util.RunSupervisor()
4139
if err != nil {
4240
fmt.Printf("Supervisor error: %v\n", err)
4341
os.Exit(1)
4442
}
4543
return
4644
}
4745

48-
// Normal execution (either supervised or auto-recovery disabled)
46+
// Normal execution (supervised process)
4947
object.InitFlag()
5048
object.InitAdapter()
5149
object.CreateTables()

supervisor/README.md

Lines changed: 0 additions & 89 deletions
This file was deleted.

supervisor/demo.sh

Lines changed: 0 additions & 187 deletions
This file was deleted.

supervisor/supervisor_test.go

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)