Operations
Restart strategy
- Prefer external schedulers (Task Scheduler/systemd/cron) to restart on fail-fast exits.
- Configure restart-on-nonzero with a short backoff (10–30s).
- Consider a daily restart before market open to refresh FYERS sessions.
Windows Task Scheduler example
schtasks /Create /TN "FYERS Broker" /SC ONCE /ST 09:00 /RL LIMITED /TR "powershell -NoProfile -Command \"cd C:\\path\\to\\custom_fyers_2; python src\\run_store.py\"" /F
schtasks /Change /TN "FYERS Broker" /RI 1 /DU 24:00 /ET 15:30
Notes:
- Configure "On task failure, restart" with a 10–30s delay and a few retries.
- Update the schedule (ST/ET) to your market hours.
systemd example (Linux)
[Unit]
Description=FYERS Broker
After=network-online.target
[Service]
Type=simple
WorkingDirectory=/opt/custom_fyers_2
ExecStart=/usr/bin/python3 /opt/custom_fyers_2/src/run_store.py
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target
cron example (Linux)
@reboot /usr/bin/python3 /opt/custom_fyers_2/src/run_store.py >> /opt/custom_fyers_2/logs/cron.out 2>&1
# Optional daily restart before market open (example: 08:50)
50 8 * * 1-5 /usr/bin/pkill -f "/opt/custom_fyers_2/src/run_store.py" && /usr/bin/python3 /opt/custom_fyers_2/src/run_store.py >> /opt/custom_fyers_2/logs/cron.out 2>&1
Notes:
- cron does not auto-restart on crashes; pair with a supervisor if needed.
- Adjust times and paths to match your environment.
supervisord example
[program:fyers_broker]
directory=/opt/custom_fyers_2
command=/usr/bin/python3 /opt/custom_fyers_2/src/run_store.py
autostart=true
autorestart=true
startretries=3
startsecs=5
stderr_logfile=/opt/custom_fyers_2/logs/supervisor.err.log
stdout_logfile=/opt/custom_fyers_2/logs/supervisor.out.log
Notes:
- Use a process control group or wrapper script if you need a daily restart window.
- Ensure logs/ exists and is writable by the supervisor user.
Notes
- Fail-fast exits are expected when reconciliation fails; rely on the scheduler to restart.
- Do not run multiple instances against the same account unless you intentionally manage order ownership and state separation.