Scheduler Patterns
This page provides operator-friendly examples for running fyers-store under a supervisor.
Windows Task Scheduler (Example)
Use Task Scheduler to restart the process on failure.
Example command:
python src/run_store.py --auth-recovery once --poll-seconds 1
Safety notes:
- Ensure FYERS_ENVIRONMENT is set correctly in the task environment.
- Do not configure aggressive restart loops; allow time for token refresh.
Linux systemd (Example)
Create a service unit that restarts on failure.
Example service:
[Unit]
Description=FYERS Store Runner
After=network.target
[Service]
WorkingDirectory=/opt/fyers-store
Environment=FYERS_ENVIRONMENT=LIVE
Environment=ALLOW_LIVE_ORDERS=true
ExecStart=/usr/bin/python /opt/fyers-store/src/run_store.py --auth-recovery once
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target
Cron (Not Recommended for Live Trading)
Cron is best for batch backtests, not continuous live trading. Use a supervisor instead.
Scenario Example
Scenario: The process exits due to AuthError. What happens: - The supervisor restarts the process. What to check: - Token freshness and auth logs. What to do next: - Refresh token manually if repeated AuthError occurs.