FAZ Auto Auth Deployment Guide

Production Systemd Architecture for Automated Script Scheduling

1. Architectural Overview

This deployment configures two isolated regional automation scripts (East and West) to run natively on a Linux server every 60 seconds. Instead of traditional Cron, execution is managed via Systemd Timers and Services. This modern structure ensures isolation, automatic environment variable extraction, robust log management via journalctl, and prevents race conditions or overlapping execution blocks.

Directory & File Structure

All scripts and localized configuration baselines are centralized under the unified /opt/gobo/ parent partition:

/opt/gobo/faz-auth/ ├── east/ │ ├── .env # East API tokens & credentials │ └── faz_auto_auth_east.py # East automation script executable └── west/ ├── .env # West API tokens & credentials └── faz_auto_auth_west.py # West automation script executable

2. Clean-Slate Setup Instructions

Follow these structural configurations precisely to replicate or build out the scheduling workspace on a new Linux server from scratch.

Step 2.1: Provision Production Infrastructure

# Create target execution boundaries
sudo mkdir -p /opt/gobo/faz-auth/east
sudo mkdir -p /opt/gobo/faz-auth/west

# Relocate scripts from standard staging spaces
sudo cp /home/zkovacs/FAZ_Auto_Auth/east/faz_auto_auth_east.py /opt/gobo/faz-auth/east/
sudo cp /home/zkovacs/FAZ_Auto_Auth/west/faz_auto_auth_west.py /opt/gobo/faz-auth/west/

# Relocate corresponding operational environment files
sudo cp /home/zkovacs/FAZ_Auto_Auth/east/.env /opt/gobo/faz-auth/east/.env
sudo cp /home/zkovacs/FAZ_Auto_Auth/west/.env /opt/gobo/faz-auth/west/.env

Step 2.2: Establish Unit Configurations

Systemd units must live in the core system module area: /etc/systemd/system/.

[A] East Configuration Block

Service Configuration: sudo vi /etc/systemd/system/faz-auth-east.service

[Unit]
Description=FAZ Auto Auth East Script
After=network.target

[Service]
Type=oneshot
User=zkovacs
WorkingDirectory=/opt/gobo/faz-auth/east
EnvironmentFile=/opt/gobo/faz-auth/east/.env
ExecStart=/usr/bin/python3 faz_auto_auth_east.py

Timer Configuration: sudo vi /etc/systemd/system/faz-auth-east.timer

[Unit]
Description=Run FAZ Auto Auth East every minute

[Timer]
OnCalendar=*-*-* *:*:00
AccuracySec=1s

[Install]
WantedBy=timers.target

[B] West Configuration Block

Service Configuration: sudo vi /etc/systemd/system/faz-auth-west.service

[Unit]
Description=FAZ Auto Auth West Script
After=network.target

[Service]
Type=oneshot
User=zkovacs
WorkingDirectory=/opt/gobo/faz-auth/west
EnvironmentFile=/opt/gobo/faz-auth/west/.env
ExecStart=/usr/bin/python3 faz_auto_auth_west.py

Timer Configuration: sudo vi /etc/systemd/system/faz-auth-west.timer

[Unit]
Description=Run FAZ Auto Auth West every minute

[Timer]
OnCalendar=*-*-* *:*:00
AccuracySec=1s

[Install]
WantedBy=timers.target

Step 2.3: Operational Activation

Register the unit files with the kernel service manager and initialize the runtime tracking engines:

# Reload daemon structural indexes
sudo systemctl daemon-reload

# Activate and start the precision timers
sudo systemctl enable --now faz-auth-east.timer
sudo systemctl enable --now faz-auth-west.timer

3. Ongoing Maintenance & Updates

Because these schedules use the oneshot Systemd service type, maintenance changes are clean and safe to perform live.

Modifying Python Scripts

When updating faz_auto_auth_east.py or faz_auto_auth_west.py, edit the script directly inside its /opt/gobo/... directory. Since a oneshot process reads and executes the script completely fresh every single minute, no service restarts or daemon reloads are required. The next automated run will pick up your code changes seamlessly.

Modifying Environment Variable (.env) Files

Systemd reads the targeted EnvironmentFile raw configurations during the initialization phase of every execution block. You can safely modify your secret keys or credentials inside the targeted .env file. The engine loads the values fresh on the next scheduled run.

CRITICAL: Modifying Systemd Service or Timer Files

If you edit any of the system profile configurations under /etc/systemd/system/ (such as modifying execution directories or scaling interval cadences), you MUST tell Systemd to refresh its internal cache, or the changes will be ignored:

sudo systemctl daemon-reload

4. Troubleshooting Guide

When an issue or unexpected result surfaces, use this targeted matrix to quickly inspect, isolate, and remediate systemic execution failures.

Essential Commands Cheat Sheet

Target Goal Execution Command
View Live Logs (Follow) sudo journalctl -u faz-auth-east.service -f
View Historical Errors sudo journalctl -u faz-auth-west.service -n 50 --no-pager
Check Timer Schedulers systemctl status faz-auth-east.timer
List Active Timers systemctl list-timers --all
Trigger Manual Execution Test sudo systemctl start faz-auth-east.service

Common Structural Failures & Resolution Blocks

1. Error State: Failed to load environment files: Permission denied

  • Cause: Systemd cannot read the .env tracking directory or file permissions are overly restrictive.
  • Fix: Verify the target .env file is readable by the designated worker user or service daemon. Run:
    sudo chmod 644 /opt/gobo/faz-auth/east/.env

2. Error State: Failed with result 'resources'

  • Cause: Usually accompanies a permission error or signifies that the targeted ExecStart file path or Python runtime environment could not be traced or opened.
  • Fix: Ensure /usr/bin/python3 is the correct path to your system's Python binary (verify with which python3). Confirm your working directories and file paths are absolute.

3. Problem State: Script works when run manually, but variables are empty when run by Timer.

  • Cause: Systemd environment variables do not use quotes the same way standard shells do, or the variable formatting inside the .env file is invalid for Systemd parsing.
  • Fix: Ensure your .env files contain clean, unquoted key-value assignments (e.g., API_KEY=xyz123, not API_KEY="xyz123"). Systemd reads quotes literally if they are present inside specified EnvironmentFile objects.