FP
This commit is contained in:
33
deploy/nginx.conf.example
Normal file
33
deploy/nginx.conf.example
Normal file
@@ -0,0 +1,33 @@
|
||||
# Reverse proxy TLS devant le serveur de contrôle.
|
||||
# Indispensable en production : les jetons d'agent et de session transitent en clair sinon.
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name control.exemple.com;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/control.exemple.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/control.exemple.com/privkey.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Upgrade WebSocket (/ws/agent et /ws/dashboard)
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# Les sessions agent sont longues : pas de coupure prématurée.
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name control.exemple.com;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
25
deploy/stream-control-agent.service
Normal file
25
deploy/stream-control-agent.service
Normal file
@@ -0,0 +1,25 @@
|
||||
# Agent Ubuntu — /etc/systemd/system/stream-control-agent.service
|
||||
#
|
||||
# L'agent doit tourner dans la MÊME session que OBS s'il pilote un OBS graphique.
|
||||
# Sur une VM headless, OBS tourne généralement sous Xvfb : garder le même User.
|
||||
#
|
||||
# systemctl daemon-reload && systemctl enable --now stream-control-agent
|
||||
|
||||
[Unit]
|
||||
Description=Stream Control — agent OBS
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=obs
|
||||
WorkingDirectory=/opt/stream-control-agent
|
||||
Environment=NODE_ENV=production
|
||||
# Chemin du fichier d'identité (jeton + agentId) — doit être inscriptible.
|
||||
Environment=AGENT_CONFIG=/opt/stream-control-agent/agent.config.json
|
||||
ExecStart=/usr/bin/node /opt/stream-control-agent/dist/index.js
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
26
deploy/stream-control-server.service
Normal file
26
deploy/stream-control-server.service
Normal file
@@ -0,0 +1,26 @@
|
||||
# Serveur de contrôle — /etc/systemd/system/stream-control-server.service
|
||||
# systemctl daemon-reload && systemctl enable --now stream-control-server
|
||||
|
||||
[Unit]
|
||||
Description=Stream Control — serveur de contrôle
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=stream
|
||||
WorkingDirectory=/opt/stream-control
|
||||
Environment=NODE_ENV=production
|
||||
ExecStart=/usr/bin/node --disable-warning=ExperimentalWarning packages/server/dist/index.js
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
# Durcissement
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=true
|
||||
ReadWritePaths=/opt/stream-control/data
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
41
deploy/windows-agent-task.ps1
Normal file
41
deploy/windows-agent-task.ps1
Normal file
@@ -0,0 +1,41 @@
|
||||
# Installe l'agent Stream Control comme tâche planifiée Windows.
|
||||
#
|
||||
# L'agent doit s'exécuter dans la session interactive de l'utilisateur qui lance
|
||||
# OBS : un service Windows classique tourne en session 0 et ne verrait pas OBS.
|
||||
# On utilise donc une tâche « à l'ouverture de session » avec redémarrage auto.
|
||||
#
|
||||
# Usage (PowerShell administrateur) :
|
||||
# .\windows-agent-task.ps1 -AgentDir 'C:\stream-control-agent' -RunAsUser 'VM01\obs'
|
||||
|
||||
param(
|
||||
[string]$AgentDir = 'C:\stream-control-agent',
|
||||
[string]$RunAsUser = "$env:USERDOMAIN\$env:USERNAME",
|
||||
[string]$TaskName = 'StreamControlAgent'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$node = (Get-Command node).Source
|
||||
$entry = Join-Path $AgentDir 'dist\index.js'
|
||||
|
||||
if (-not (Test-Path $entry)) {
|
||||
throw "Agent introuvable : $entry — copie d'abord packages/agent (dist + node_modules) dans $AgentDir"
|
||||
}
|
||||
if (-not (Test-Path (Join-Path $AgentDir 'agent.config.json'))) {
|
||||
Write-Warning "agent.config.json absent de $AgentDir : l'agent refusera de démarrer sans jeton."
|
||||
}
|
||||
|
||||
$action = New-ScheduledTaskAction -Execute $node -Argument "`"$entry`"" -WorkingDirectory $AgentDir
|
||||
$trigger = New-ScheduledTaskTrigger -AtLogOn -User $RunAsUser
|
||||
$principal = New-ScheduledTaskPrincipal -UserId $RunAsUser -LogonType Interactive -RunLevel Limited
|
||||
$settings = New-ScheduledTaskSettingsSet `
|
||||
-AllowStartIfOnBatteries -DontStopIfGoingOnBatteries `
|
||||
-RestartCount 999 -RestartInterval (New-TimeSpan -Minutes 1) `
|
||||
-ExecutionTimeLimit ([TimeSpan]::Zero) -MultipleInstances IgnoreNew
|
||||
|
||||
Register-ScheduledTask -TaskName $TaskName -Action $action -Trigger $trigger `
|
||||
-Principal $principal -Settings $settings -Force | Out-Null
|
||||
|
||||
Start-ScheduledTask -TaskName $TaskName
|
||||
Write-Host "Tâche « $TaskName » installée et démarrée pour $RunAsUser."
|
||||
Write-Host "Journal : Get-ScheduledTaskInfo -TaskName $TaskName"
|
||||
Reference in New Issue
Block a user