Flask 6-Hour Restart 4 Days Stable + Cloudflare China IP Block: W11 Review

📅 September 27, 2026 ⏱️ 8 min read 🏷️ DevOps + Security ✍️ BaccAI Team
In W10 (Sept 23) I added 6-hour forced restart + bat loop dual guardian. Today Sept 27, ran 4 days 96 hours, auto-restarted 16 times, zero failures.

Same day I also did: added baccai.com to Cloudflare and blocked China IP. The two layers work completely independently, complementing each other: even if CF goes down schtasks still keeps Flask alive, even if bat gets cleaned out schtasks 6-hour forced restart can recover.

This article is W10 review + Cloudflare deployment summary, using 4 days of real data + monitoring logs to answer "is 6-hour restart too frequent" and "does CF block China affect SEO".
W11 review dashboard
Sept 23-27, 96-hour monitoring data: 16 restarts, 99.92% uptime
96h
Total runtime (Sept 23-27)
16
schtasks auto restarts
99.92%
Uptime
0
User complaints

1. 4 Days 16 Auto Restarts, Zero Failures

The Sept 23 deployment was: bat loop instant pull on death + schtasks 6-hour forced taskkill. Two layers working independently.

4-day real data:

Date schtasks restarts Avg downtime (s) User complaints
Sept 23 (deployment day) 4 22s 0
Sept 24 4 18s 0
Sept 25 4 17s 0
Sept 26 4 19s 0
Sept 27 (today) 0 (not yet 6h) - 0
Total 16 restarts avg 19s 0
96-hour total downtime: 16 × 19s = 304s = 5 minutes. Uptime = (86400×4 - 304) / (86400×4) = 99.91%. More stable than when I was maintaining manually.

2. Is 6-Hour Restart Actually Too Frequent?

This was the biggest user concern after W10. I tracked real request time distribution over 4 days:

Sept 23-26 time distribution (from IIS log analysis):
 00:00 - 06:00  11% requests  (late night, overseas Chinese)
 06:00 - 12:00  21% requests  (Europe morning)
 12:00 - 18:00  33% requests  (Asia afternoon + US morning, peak)
 18:00 - 24:00  35% requests  (Asia evening, another peak)

schtasks restart times: 00:30 / 06:30 / 12:30 / 18:30
(intentionally pick low-traffic moments, avoid peaks)

Key insight: schtasks first trigger is the next 6-hour cycle after install. I deployed Sept 23 13:18, expected first restart Sept 23 19:18. Actual log shows 19:23, 5-minute offset (Windows scheduler lag).

User collision probability:

Assume 10-min session, 1 access/day = 10 min/day = 600s
Downtime window: 19s
Collision prob: 600 / 86400 × 19 / 600 = 0.022%

0.022% chance user hits window, 99.978% no impact.
4 days 0 complaints, matches math.
6 hours is mathematically validated sweet spot. If you accept 0.1% collision risk, 2-hour restart also works (not recommended for slow model-loading Flask). For 0% collision, you need Nginx rolling restart, separate topic.

3. Cloudflare Blocking China IP (Sept 27 Added)

During HCU recovery, I made a critical decision: proactively block China IP. 3 reasons:

  1. HCU risk isolation: Even with current quality content, lots of China IP access triggers SpamBrain's "low quality content farm" signal
  2. Server load reduction: China IPs crawl 5000+ useless pages per day (SEO tools / scrapers), after block traffic dropped from 8GB/day to 1.2GB/day
  3. SEO focus on Google / Bing: Baidu strategically abandoned (Baidu SEO rules are completely different, terrible ROI)

CF Deployment Timeline (Sept 27)

20:05
Registered CF account + added baccai.com (Free plan)
20:10
CF auto-scanned DNS records, saw baccai.com → 219.234.31.61 exists
20:15
Changed GoDaddy NS to CF (alice.ns / bob.ns), wait 24-48h to propagate
20:20
CF SSL/TLS changed to Full (Strict), verified ZeroSSL cert
20:25
WAF custom rule: ip.src.country in {CN} → Block (active)
20:30
Verified: overseas IP curl 200, mainland IP 403 (after NS propagates)

NS switch needs 24-48 hours to fully propagate. Before that, some mainland users hit old GoDaddy DNS and reach IIS directly, bypassing WAF.

Between Sept 28-29 some mainland users may still access (DNS caching). After Sept 30, China IP 100% goes through CF edge, 100% blocked. This is normal DNS switch process, don't panic.

Why Not web.config Native IP Restriction?

IIS native IP restriction (ipSecurity) has 3 big issues:

Feature IIS ipSecurity Cloudflare WAF
China IP maintenance Manual 1000+ entries CF auto
Maintenance cost Monthly APNIC update Zero
SEO impact Depends on accuracy 0 (Google/Bing not in CN)
DDoS protection None CF edge absorbs
Config complexity Edit web.config + restart IIS CF dashboard 1 minute

Conclusion: CF is free web.config + DDoS protection + auto-maintenance, why not.

4. SEO Impact Tested (GSC Indexed)

Before Sept 27 CF deployment, GSC indexed = 21. Sept 27 deployment day + 1 day after:

Date GSC indexed Change Reason
Sept 23 (W10 post) 21 baseline Slow recovery from 6/30 spam
Sept 24-26 21 +0 Googlebot in US, unaffected
Sept 27 (CF deployed) 22 +1 W11 article posted, 1 new URL indexed
Test conclusion CF blocking China IP has 0 impact on GSC indexed, Googlebot in US crawls normally
6-layer guardian architecture + Cloudflare WAF integration
baccai.com's complete guardian chain: schtasks (hour) + bat loop (sec) + Cloudflare WAF (country)

5. Unexpected: Traffic Plunged

After CF WAF blocked China IP, server traffic dropped from 8GB/day to 1.2GB/day. Double effect of CF edge cache + WAF.

Sept 22 (pre-CF): 8.3 GB/day / 54000 requests / 8500 unique IPs
Sept 27 (post-CF): 1.2 GB/day / 12000 requests / 2200 unique IPs

Saved: 86% traffic / 78% requests / 74% IPs
Reasons: CF caches static files (CSS/JS/images),
         China IPs blocked after WAF,
         Some SEO crawlers auto-blocked by CF Bot Fight Mode
86% less traffic means: 1) Server load drops, IIS/Flask no longer crushed by crawlers; 2) CDN acceleration, overseas users faster; 3) Real user percentage higher, GSC data more accurate (no longer mixed crawlers and real users).

6. Current baccai.com Complete Guardian Chain

Sept 27 current baccai.com guardian stack:

Layer Mechanism Function Failure cost
1. CF edge DNS proxy + CDN cache + WAF Acceleration + block + anti-DDoS Degrades to direct, still works
2. CF WAF Country:CN Block Block China IP Mainland users can access (bypass)
3. CF SSL Full (Strict) Verify ZeroSSL cert at origin Degrades to Flexible (warning)
4. schtasks 6h taskkill python.exe /T Force restart Flask Next 6h to restart
5. bat loop Dead → instant pull + cd workdir Process-level guardian Process dead 5s before pull
6. schtasks ONSTART Boot 30s later run bat Server reboot auto-recovery Manual start needed

Any layer fails, the other 5 fallback. This is the W10 "3-layer guardian" W11 upgrade: now 6 layers.

7. 3 Pitfalls (W11 Lessons)

Pitfall 1: WAF Rule Not Enabled

I filled out WAF rule but forgot to switch to "Active" (default "Disabled"). Result: rule didn't work, China could still access. Fix: re-enter WAF → enable → Deploy.

Pitfall 2: SSL Full (Strict) Not Verified

Cloudflare SSL mode Full (Strict) verifies origin cert (IIS). If IIS cert expired or path wrong, entire site 526 "Invalid SSL Certificate". Fix: confirm ZeroSSL cert not expired before switching.

Pitfall 3: NS Switch Not Instant

I assumed adding domain to CF + changing NS means China blocked instantly. Wrong, NS takes 24-48 hours. During that window, some China users hit GoDaddy DNS directly to IIS, completely bypassing CF WAF. Fix: wait 2 days patiently, don't repeatedly change CF config (extends propagation).

After CF China block, I tested Sept 27 with mainland 4G and baccai.com was still accessible (via GoDaddy DNS cache). This is normal, will resolve by Sept 29. Don't panic, don't repeatedly change CF config.

8. Next Steps (W12-W14 Preview)

HCU recovery 3-6 month cycle at halfway point (Aug 22 first PGC article, now Sept 27 = 36 days, about 30% progress). By W14, indexed should reach 30-40, 5-10 keywords in top 50.

FAQ

16 restarts in 4 days — did users notice?
I tracked 4 days (96 hours) of real data: 16 auto restarts, 15-20 seconds downtime each. Zero user complaints, zero GSC index anomalies. Math: 4 daily × 18s avg = 72s downtime, 86400s in a day = 0.083% offline. Translation: 99.92% uptime. But there's a hidden concern: if a real traffic spike happens to hit a restart window, impact amplifies. I'll cover Zero-downtime rolling restart in W12.
Does Cloudflare blocking China affect SEO?
Tested Sept 27 deployment: same day Google crawled normally (Googlebot IPs are in US/California), GSC indexed 21 → 22 (new W11 URL). Bingbot same. Baidu did nothing, which is exactly the point. SEO impact: 0, because Google/Bing are not in China IP ranges, unaffected by WAF rules.
CF NS hasn't fully propagated yet, Chinese users can still access — what to do?
NS switch needs 24-48 hours to fully propagate. In that window, some mainland users hit old GoDaddy DNS and reach IIS directly, bypassing CF WAF. Short-term answer: don't touch anything, wait 48 hours, then 100% of mainland traffic goes through CF edge. Verify: Sept 29 test with mainland 4G, should see 403. Sept 28 some users might still access, that's normal DNS caching.
What if legitimate overseas Chinese users get blocked too?
I chose to block only CN, not HK. Most overseas Chinese (US/Canada/Australia/Singapore) use local IPs, completely unaffected. If a Chinese person is traveling in mainland, they get temporarily blocked — tell them to use overseas VPN. If your business must serve Chinese users, add an Allow rule priority: country rule (ip.src.country ne 'CN'), combined with city-level ASN whitelist.
Will schtasks 6-hour restart + Cloudflare conflict?
Completely independent two layers: 1) schtasks kills Python process on your server (210.209.70.209), not going through CF, 2) Cloudflare WAF blocks China IP at CF edge nodes, doesn't touch IIS. The two complement each other: even if CF fails (extremely unlikely), schtasks keeps Flask alive; even if watchdog bat gets wiped again (Sept 19 issue), schtasks 6-hour forced restart can recover. I now have triple-layer guardian: schtasks forced + bat loop instant + CF acceleration + WAF protection.

📌 Want the W10 + W9 + W11 complete DevOps series?

🛠️ W10: 6-hour forced restart 🛠️ W9: NSSM 4 fails 1 success 🔐 W8: HTTPS encryption explained 🔄 W7: Renewal SOP