extra/no-as-a-service | ||
.rubocop.yml | ||
app.rb | ||
Containerfile | ||
Gemfile | ||
Gemfile.lock | ||
languages.rb | ||
no-as-a-service.jpg | ||
no-as-a-service.service | ||
no.jpg | ||
noaas.jpg | ||
README.md |
No-as-a-Service
This is a simple Ruby web service that responds with "No" in various languages. It's designed to accept both HTML and JSON requests and includes rate limiting, structured logging, and support for deployment using Podman and systemd.
Features
- Returns "No" in multiple languages and styles.
- Supports both HTML and JSON response formats.
- Rate limiting to avoid abuse (30 requests per minute per IP).
- Logs structured output, forwarding logs to journald for integration with systemd.
Files
- app.rb: The main Ruby application file with Sinatra web service.
- Containerfile: Instructions for building the container image using Podman.
- no-as-a-service.service: systemd service configuration for managing the application.
Installation & Deployment
Prerequisites
- Podman: To build and run the container.
- systemd: For managing the service.
- Journald: For logging.
Step 1: Build the Container Image
Clone the repository or download the files, and navigate to the folder containing the Containerfile
and app.rb
.
Run the following command to build the container image with Podman:
podman build -t noaas .
Step 2: Create the systemd Service
Copy the no-as-a-service.service
file to your systemd service directory:
sudo cp no-as-a-service.service /etc/systemd/system/
Enable and start the service:
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable --now no-as-a-service
Step 3: Accessing the Service
Once the service is running, you can access it at:
- HTML Response: Open a browser and visit
http://localhost:8080/
. - JSON Response: Send a GET request to
http://localhost:8080/
with anAccept: application/json
header, or append?format=json
to the URL.
Logs
Logs are forwarded to Journald. You can view logs using:
journalctl -u no-as-a-service -t noaas -f
Rate Limiting
Each IP is limited to 30 requests per minute. If this limit is exceeded, the response will be a 429 Too Many Requests
status with a JSON error message.
Customizing Language Responses
You can customize the "No" responses in various languages by modifying the NO_RESPONSES
hash in app.rb
.
License
This project is licensed under the MIT License - see the LICENSE file for details.