++ fix
This commit is contained in:
@@ -46,7 +46,6 @@ else
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import signal
|
||||
import time
|
||||
|
||||
sync_configs_json = os.environ.get('SYNC_CONFIGS', '[]')
|
||||
@@ -64,18 +63,33 @@ print(f"[ENTRYPOINT] Avvio {len(configs)} sync...")
|
||||
|
||||
processes = []
|
||||
for i, cfg in enumerate(configs):
|
||||
sync_id = cfg.get('id', f'sync{i}')
|
||||
bucket = cfg.get('bucket', 'default')
|
||||
sync_id = cfg.get('id', f'sync{i+1}')
|
||||
bucket = cfg.get('bucket')
|
||||
local_path = cfg.get('local_path') or cfg.get('path') or f'/data/local{i+1}'
|
||||
interval = str(cfg.get('interval', os.environ.get('SYNC_INTERVAL', '300')))
|
||||
prefix = cfg.get('prefix', os.environ.get('S3_PATH_PREFIX', ''))
|
||||
schedule = cfg.get('schedule', os.environ.get('SYNC_SCHEDULE', ''))
|
||||
|
||||
if not bucket:
|
||||
print(f"[ERROR] Config sync '{sync_id}' senza campo 'bucket'")
|
||||
exit(1)
|
||||
|
||||
state_dir = f"/data/state/{sync_id}"
|
||||
|
||||
print(f"[ENTRYPOINT] Avvio sync {i+1}/{len(configs)}: {sync_id} (bucket: {bucket})")
|
||||
print(f"[ENTRYPOINT] Avvio sync {i+1}/{len(configs)}: {sync_id} (bucket: {bucket}, local: {local_path})")
|
||||
|
||||
# Crea directory di stato
|
||||
os.makedirs(state_dir, exist_ok=True)
|
||||
os.makedirs(local_path, exist_ok=True)
|
||||
|
||||
# Lancia sync.sh in background con STATE_DIR specifico
|
||||
env = os.environ.copy()
|
||||
env['STATE_DIR'] = state_dir
|
||||
env['S3_BUCKET'] = bucket
|
||||
env['LOCAL_PATH'] = local_path
|
||||
env['SYNC_INTERVAL'] = interval
|
||||
env['S3_PATH_PREFIX'] = prefix
|
||||
env['SYNC_SCHEDULE'] = schedule
|
||||
|
||||
proc = subprocess.Popen(
|
||||
['/usr/local/bin/sync.sh'],
|
||||
|
||||
Reference in New Issue
Block a user