# diun

## Overview
The `diun` stack is a Docker Swarm service that runs in NetGrimoire, providing monitoring and notification capabilities for the network.

---

## Architecture
| Service | Image | Port | Role |
|---------|-------|-----|------|
- **Host:** docker4
- **Network:** netgrimoire
- **Exposed via:** `caddy-diun:80` (Internal only)
- **Homepage group:** homepage

---

## Build & Configuration

### Prerequisites
This service requires Docker and a Swarm manager node to be running.

### Volume Setup
```bash
mkdir -p /DockerVol/diun
```

### Environment Variables
```bash
# generate: openssl rand -hex 32
DIUN_NOTIF_NTFY_ENDPOINT= https://ntfy.netgrimoire.com
DIUN_NOTIF_NTFY_TOPIC=netgrimoire-diun
```

### Deploy
```bash
cd services/swarm/stack/diun
set -a && source .env && set +a
docker stack config --compose-file diun-stack.yml > resolved.yml
docker stack deploy --compose-file resolved.yml diun
rm resolved.yml
docker stack services diun
```

### First Run
Run `./deploy.sh` to initialize the service after deployment.

---

## User Guide

### Accessing diun
| Service | URL |
|---------|-----|
| diun | https://caddy-diun:80 |

### Primary Use Cases
This service is used for monitoring and notification of network events in NetGrimoire.

### NetGrimoire Integrations
This service integrates with other services such as `kuma` for monitoring and `caddy` for reverse proxying.

---

## Operations

### Monitoring
[kuma monitors from kuma.* labels]
```bash
docker stack services diun
docker service logs -f diun
```

### Backups
Critical data is stored in `/DockerVol/diun`. Regular backups are not implemented yet.

### Restore
```bash
cd services/swarm/stack/diun
./deploy.sh
```

---

## Common Failures
| Symptom | Cause | Fix |
|---------|------|-----|
| Diun service not running | Swarm manager node down | Restart swarm manager node |
| Monitoring not working | `kuma` service not running | Check `kuma` service status and restart if necessary |

---

## Changelog

| Date | Commit | Summary |
|------|--------|---------|
| 2026-04-29 | 589fb156 | Initial documentation and Swarm configuration |
| 2026-04-29 | d2b325f8 | Added environment variables for notification settings |
| 2026-04-29 | a343f343 | Improved volume setup and cleanup |
| 2026-04-07 | 247956f0 | Added primary use case section to user guide |
| 2026-04-07 | 27c8306d | Added NetGrimoire integrations section to user guide |

<Write a paragraph summarizing the evolution of this service based on the diffs above. If no diffs available, note that this is the initial documentation.>

---

## Notes
- Generated by Gremlin on 2026-04-30T03:18:12.482Z
- Source: swarm/diun.yaml
- Review User Guide and Changelog sections