# Boot Configuration - API Auto-Start

## Current Status

✅ **Service is ENABLED** - The API will automatically start when the server boots.

✅ **Mount is configured** - The contentstore mount is in `/etc/fstab` and will mount automatically on boot.

## How It Works

### Service Configuration

The systemd service file (`plagis-aumentum-api.service`) is configured with:

- **`After=network-online.target`** - Waits for network to be fully available
- **`RequiresMountsFor=/mnt/aumentum_contentstore`** - Ensures the contentstore mount is available before starting
- **`Restart=always`** - Automatically restarts if the service crashes
- **`WantedBy=multi-user.target`** - Starts during normal boot sequence

### Boot Sequence

1. Server boots
2. Network comes online
3. Contentstore mounts (from `/etc/fstab`)
4. API service starts automatically
5. Service waits for mount to be ready
6. API begins serving requests

## Verification

Run this script to verify boot configuration:

```bash
bash scripts/verify_boot_setup.sh
```

Or manually check:

```bash
# Check if service is enabled
sudo systemctl is-enabled plagis-aumentum-api

# Check if mount is in fstab
grep aumentum_contentstore /etc/fstab

# Check current status
sudo systemctl status plagis-aumentum-api
```

## Troubleshooting

### Service Not Starting on Boot

If the service doesn't start on boot:

```bash
# Enable the service
sudo systemctl enable plagis-aumentum-api

# Verify it's enabled
sudo systemctl is-enabled plagis-aumentum-api
```

### Mount Not Available

If the mount fails on boot, the service will wait but may eventually fail. Check:

```bash
# Check mount status
mountpoint /mnt/aumentum_contentstore

# Check fstab entry
cat /etc/fstab | grep aumentum

# Test mount manually
sudo mount -a
```

### Service Starts Before Mount

The service is configured with `RequiresMountsFor=/mnt/aumentum_contentstore`, which should prevent this. If you still have issues:

1. Check mount logs: `dmesg | grep -i cifs`
2. Verify credentials file: `sudo cat /root/.smb_credentials_aumentum`
3. Test network connectivity: `ping 10.10.10.5`

## Testing Boot Configuration

To test without rebooting:

```bash
# Stop the service
sudo systemctl stop plagis-aumentum-api

# Unmount contentstore
sudo umount /mnt/aumentum_contentstore

# Start service (it should wait for mount)
sudo systemctl start plagis-aumentum-api

# Check status
sudo systemctl status plagis-aumentum-api

# Mount contentstore
sudo mount -a

# Service should now start successfully
```

## Summary

✅ **Yes, the API will automatically start when the server reboots.**

The configuration ensures:
- Service starts after network is ready
- Service waits for contentstore mount
- Service auto-restarts if it crashes
- Everything is configured for automatic startup

