add logging to whitelister
This commit is contained in:
parent
c71cadd589
commit
423819d6c3
@ -84,6 +84,9 @@ jobs:
|
||||
- name: opentracker service check
|
||||
run: curl http://opentracker:8666/stats
|
||||
|
||||
- name: opentracker whitelister service check
|
||||
run: curl http://opentracker:8666/whitelister
|
||||
|
||||
- name: Check postgres pingability
|
||||
run: ping -c 3 db
|
||||
|
||||
|
@ -5,7 +5,7 @@ defmodule Bright.CreateTorrentTest do
|
||||
|
||||
alias Bright.ObanWorkers.{ProcessVod, CreateTorrent}
|
||||
alias Bright.Streams
|
||||
alias Bright.Streams.{Stream, Vod}
|
||||
alias Bright.Streams.Stream
|
||||
alias Bright.Torrents.Torrent
|
||||
|
||||
describe "CreateTorrent" do
|
||||
|
@ -5,8 +5,6 @@ defmodule BrightWeb.AuthControllerTest do
|
||||
require Logger
|
||||
|
||||
@patron_tier_1_required_error "This route is for tier 1 or higher."
|
||||
@patron_tier_2_required_error "This route is for tier 2 or higher."
|
||||
@patron_tier_3_required_error "This route is for tier 3 or higher."
|
||||
|
||||
describe "patreon auth" do
|
||||
test "successful auth on existing user sets the session", %{conn: conn} do
|
||||
|
@ -75,6 +75,6 @@ ADD https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY
|
||||
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
|
||||
ADD https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
|
||||
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz
|
||||
ENTRYPOINT /init
|
||||
ENTRYPOINT ["/init"]
|
||||
# CMD ["/etc/s6-overlay/s6-rc.d/svc-opentracker/run"] # IDK if this is correct
|
||||
# USER 6969 # I think we can instead drop privs via s6
|
@ -2,6 +2,6 @@
|
||||
|
||||
export PORT=3001
|
||||
|
||||
exec 2>&1
|
||||
exec s6-setuidgid farmhand \
|
||||
exec node /etc/whitelister/index.js
|
||||
|
||||
exec s6-setuidgid farmhand node /etc/whitelister/index.js
|
||||
|
||||
|
@ -1,41 +1,50 @@
|
||||
const http = require('http');
|
||||
const fs = require('fs');
|
||||
const packagejson = require('./package.json');
|
||||
|
||||
const port = process.env.PORT || 3000
|
||||
|
||||
// Set up the FIFO path
|
||||
const port = process.env.PORT || 3000;
|
||||
const fifoPath = '/var/run/opentracker/adder.fifo';
|
||||
|
||||
// Create a simple HTTP server
|
||||
console.log(`[${new Date().toISOString()}] Starting whitelister server ${packagejson.version} on port ${port}`);
|
||||
|
||||
const server = http.createServer((req, res) => {
|
||||
const requestStart = Date.now();
|
||||
console.log(`[${new Date().toISOString()}] Incoming request: ${req.method} ${req.url}`);
|
||||
|
||||
if (req.method === 'POST') {
|
||||
let body = '';
|
||||
|
||||
// Collect the request body data
|
||||
req.on('data', chunk => {
|
||||
body += chunk;
|
||||
});
|
||||
|
||||
req.on('end', () => {
|
||||
// Write to the FIFO
|
||||
console.log(`[${new Date().toISOString()}] Received POST body: ${body}`);
|
||||
|
||||
fs.appendFile(fifoPath, body + '\n', err => {
|
||||
if (err) {
|
||||
console.error(`[${new Date().toISOString()}] ERROR writing to FIFO: ${err.message}`);
|
||||
res.statusCode = 500;
|
||||
res.end('Error writing to FIFO');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[${new Date().toISOString()}] Successfully added to whitelist`);
|
||||
res.statusCode = 200;
|
||||
res.end('Successfully added to whitelist');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
console.warn(`[${new Date().toISOString()}] Method not allowed: ${req.method} ${req.url}`);
|
||||
res.statusCode = 405;
|
||||
res.end('Method Not Allowed');
|
||||
}
|
||||
|
||||
res.on('finish', () => {
|
||||
console.log(`[${new Date().toISOString()}] Response sent. Status: ${res.statusCode}. Duration: ${Date.now() - requestStart}ms`);
|
||||
});
|
||||
});
|
||||
|
||||
// Listen on port 8080
|
||||
server.listen(port, () => {
|
||||
console.log(`Whitelister server running on http://localhost:${port}`);
|
||||
console.log(`[${new Date().toISOString()}] Whitelister server ${packagejson.version} running on http://localhost:${port}`);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user