Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 15d9eba987 | |||
| 05d6d299da | |||
| ab9db1211c |
+16
-4
@@ -1313,9 +1313,17 @@ def _initialize_scheduler():
|
||||
if lock_age > 300: # 5 minutes - indicates a stale lock from a previous container run
|
||||
os.remove(scheduler_lock_path)
|
||||
app.logger.info(f"Removed stale scheduler lock file (age: {lock_age:.0f}s)")
|
||||
except Exception:
|
||||
pass # If we can't clean up, continue anyway
|
||||
|
||||
except Exception as e:
|
||||
app.logger.warning(f"Could not clean up scheduler lock file: {e}")
|
||||
|
||||
# Always try to remove lock file on startup (extra safety)
|
||||
try:
|
||||
if os.path.exists(scheduler_lock_path):
|
||||
os.remove(scheduler_lock_path)
|
||||
app.logger.info("Scheduler lock file removed on startup.")
|
||||
except Exception as e:
|
||||
app.logger.warning(f"Could not remove scheduler lock file on startup: {e}")
|
||||
|
||||
try:
|
||||
# Try to create the lock file - only succeeds if it doesn't exist
|
||||
lock_fd = os.open(scheduler_lock_path, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o644)
|
||||
@@ -1324,7 +1332,7 @@ def _initialize_scheduler():
|
||||
except FileExistsError:
|
||||
should_start = False
|
||||
app.logger.warning("Scheduler lock exists - another process is already running the scheduler")
|
||||
|
||||
|
||||
if should_start:
|
||||
scheduler.add_job(func=create_daily_backup, trigger="interval", hours=cfg.BACKUP_INTERVAL_HOURS)
|
||||
scheduler.add_job(func=update_appointment_statuses, trigger="interval", minutes=cfg.SCHEDULER_INTERVAL_MIN)
|
||||
@@ -10806,6 +10814,10 @@ def get_optimal_image_quality(img, target_size_kb=80):
|
||||
# PUSH NOTIFICATION API ENDPOINTS
|
||||
# ============================================================================
|
||||
|
||||
@app.route('/health')
|
||||
def health_check():
|
||||
return 'OK', 200
|
||||
|
||||
@app.route('/api/push/subscribe', methods=['POST'])
|
||||
def subscribe_to_push():
|
||||
"""
|
||||
|
||||
@@ -13,6 +13,6 @@ redis
|
||||
reportlab
|
||||
python-barcode
|
||||
openpyxl
|
||||
cryptography
|
||||
cryptography>=42.0.0
|
||||
pywebpush
|
||||
py-vapid==1.9.0
|
||||
py-vapid>=1.9.0
|
||||
|
||||
@@ -50,7 +50,7 @@ services:
|
||||
- "${INVENTAR_HTTP_PORT:-80}:80"
|
||||
- "${INVENTAR_HTTPS_PORT:-8000}:8000"
|
||||
volumes:
|
||||
- ./docker/nginx/multitenant.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
- ./docker/nginx/multitenant.conf:/etc/nginx/conf.d/default.conf
|
||||
- ./certs:/etc/nginx/certs:ro
|
||||
- ./docker/nginx/acme:/etc/nginx/acme:ro
|
||||
networks:
|
||||
|
||||
+2
-2
@@ -12,6 +12,6 @@ redis
|
||||
reportlab
|
||||
python-barcode
|
||||
openpyxl
|
||||
cryptography
|
||||
cryptography>=42.0.0
|
||||
pywebpush
|
||||
py-vapid==1.9.0
|
||||
py-vapid>=1.9.0
|
||||
|
||||
@@ -115,7 +115,10 @@ ensure_nginx_config_mount_source() {
|
||||
|
||||
if [ ! -f "$config_path" ]; then
|
||||
cat > "$config_path" <<'EOF'
|
||||
server {
|
||||
fi
|
||||
}
|
||||
|
||||
server() {
|
||||
listen 80;
|
||||
server_name _;
|
||||
return 301 https://$host$request_uri;
|
||||
@@ -521,9 +524,29 @@ verify_stack_health() {
|
||||
return 1
|
||||
}
|
||||
|
||||
cleanup_server_space() {
|
||||
log_message "Running server cleanup before update..."
|
||||
# Remove unused Docker objects
|
||||
if docker system prune -af --volumes >> "$LOG_FILE" 2>&1; then
|
||||
log_message "Docker system pruned (all unused images, containers, volumes, networks)"
|
||||
else
|
||||
log_message "WARNING: Docker system prune failed"
|
||||
fi
|
||||
# Clean up old dist artifacts
|
||||
cleanup_old_dist_artifacts
|
||||
# Clean up log files older than 7 days
|
||||
if find "$LOG_DIR" -type f -name '*.log' -mtime +7 -exec rm -f {} +; then
|
||||
log_message "Old log files (older than 7 days) cleaned up"
|
||||
else
|
||||
log_message "WARNING: Failed to clean up old log files"
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
parse_args "$@"
|
||||
|
||||
cleanup_server_space
|
||||
|
||||
ensure_runtime_dependencies
|
||||
ensure_tls_certificates
|
||||
ensure_nginx_config_mount_source
|
||||
|
||||
Reference in New Issue
Block a user