Update Main to monorepo structure (#5)

* feat: Convert to a webhooks api model!

feat: Update readme with new api docs and images and logo

feat: reoptimize jpgs and add comments to all images for credit

feat: Add database backend implementations
Todo is to update the readme

feat: use memory storage for endpoints

feat: add logging to rest api and remove ctrl override

feat: remove keyboard monitor

delete the discord api from direct reference

* feat: webhook sending with retries and backoff

Also some great readme changes

* feat: add a web based dev mode!

* feat: better error handling for webhook endopoints

* feat: remove verbose logs

* feat: add docs for local dev

* feat: remove complex webhook stuff
config file with endpoints listed instead

* feat: update logo

* feat: set endpoint and remove rest api

* fix: check for negative config numbers

* feat: remove timestamps from webhook
Use Date header instead

* feat: refactor to using one endpoint with env vars

* feat: change logging to be one rolling log
With a max line size of 10k lines

* feat: move config to toml, keep api in env var

* feat: use .env files for managing env vars

* fix: remove log files from dev

* fix: unblock web monitor thread

* feat: merge into a monorepo with noisebridge-status
This commit is contained in:
Jet Pham 2025-08-05 00:33:41 -05:00 committed by GitHub
parent 716153b1b6
commit dff2e96947
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
54 changed files with 6967 additions and 973 deletions

View file

@ -1,82 +0,0 @@
# Noisebell
A switch monitoring system that detects circuit state changes via GPIO and sends webhook notifications to configured endpoints.
This is build by Jet Pham to be used at Noisebridge to replace their old discord status bot
## Features
- GPIO circuit monitoring with configurable pin
>TODO: - Webhook notifications with retry mechanism
>TODO: - REST API for managing webhook endpoints
- Daily rotating log files
- Cross-compilation support for Raspberry Pi deployment
> Temporarialy calls the discord bot directly
- Debouncing using a finite state machine
## Requirements
- Rust toolchain
- Raspberry Pi (tested on aarch64)
- For development: Cross-compilation tools (for `cross` command)
## Installation
1. Clone the repository:
```bash
git clone https://github.com/yourusername/noisebell.git
cd noisebell
```
2. Build the project:
```bash
cargo build --release
```
## Deployment
The project includes a deployment script for Raspberry Pi. To deploy:
1. Ensure you have cross-compilation tools installed:
```bash
cargo install cross
```
2. Run the deployment script:
```bash
./deploy.sh
```
This will:
- Cross-compile the project for aarch64
- Copy the binary and configuration to your Raspberry Pi
- Set appropriate permissions
## Logging
Logs are stored in the `logs` directory with daily rotation for the past 7 days
## Configuration
The following parameters can be configured in `src/main.rs`:
### GPIO Settings
- `DEFAULT_GPIO_PIN`: The GPIO pin number to monitor (default: 17)
- `DEFAULT_POLL_INTERVAL_MS`: How frequently to check the GPIO pin state in milliseconds (default: 100ms)
- `DEFAULT_DEBOUNCE_DELAY_SECS`: How long the switch must remain in a stable state before triggering a change, in seconds (default: 5s)
### Discord Settings
The following environment variables must be set:
- `DISCORD_TOKEN`: Your Discord bot token
- `DISCORD_CHANNEL_ID`: The ID of the channel where status updates will be posted
### Logging Settings
- `LOG_DIR`: Directory where log files are stored (default: "logs")
- `LOG_PREFIX`: Prefix for log filenames (default: "noisebell")
- `LOG_SUFFIX`: Suffix for log filenames (default: "log")
- `MAX_LOG_FILES`: Maximum number of log files to keep (default: 7)
To modify these settings:
1. Edit the constants in `src/main.rs`
2. Rebuild the project
3. For Discord keys and channel id, ensure the environment variables are set before running the bot (Done for you in deploy.sh)