| 876 | |
| 877 | |
| 878 | def start_server( |
| 879 | store: "feast.FeatureStore", |
| 880 | host: str, |
| 881 | port: int, |
| 882 | no_access_log: bool, |
| 883 | workers: int, |
| 884 | worker_connections: int, |
| 885 | max_requests: int, |
| 886 | max_requests_jitter: int, |
| 887 | keep_alive_timeout: int, |
| 888 | registry_ttl_sec: int, |
| 889 | tls_key_path: str, |
| 890 | tls_cert_path: str, |
| 891 | metrics: bool, |
| 892 | ): |
| 893 | if (tls_key_path and not tls_cert_path) or (not tls_key_path and tls_cert_path): |
| 894 | raise ValueError( |
| 895 | "Both key and cert file paths are required to start server in TLS mode." |
| 896 | ) |
| 897 | |
| 898 | fs_cfg = getattr(store.config, "feature_server", None) |
| 899 | metrics_cfg = getattr(fs_cfg, "metrics", None) |
| 900 | metrics_from_config = getattr(metrics_cfg, "enabled", False) |
| 901 | metrics_active = metrics or metrics_from_config |
| 902 | uses_gunicorn = sys.platform != "win32" |
| 903 | if metrics_active: |
| 904 | flags = feast_metrics.build_metrics_flags(metrics_cfg) |
| 905 | feast_metrics.start_metrics_server( |
| 906 | store, |
| 907 | metrics_config=flags, |
| 908 | start_resource_monitoring=not uses_gunicorn, |
| 909 | ) |
| 910 | |
| 911 | logger.debug("start_server called") |
| 912 | auth_type = str_to_auth_manager_type(store.config.auth_config.type) |
| 913 | logger.info(f"Auth type: {auth_type}") |
| 914 | init_security_manager(auth_type=auth_type, fs=store) |
| 915 | logger.debug("Security manager initialized successfully") |
| 916 | init_auth_manager( |
| 917 | auth_type=auth_type, |
| 918 | server_type=ServerType.REST, |
| 919 | auth_config=store.config.auth_config, |
| 920 | ) |
| 921 | logger.debug("Auth manager initialized successfully") |
| 922 | |
| 923 | if uses_gunicorn: |
| 924 | options = { |
| 925 | "bind": f"{host}:{port}", |
| 926 | "accesslog": None if no_access_log else "-", |
| 927 | "workers": workers, |
| 928 | "worker_connections": worker_connections, |
| 929 | "max_requests": max_requests, |
| 930 | "max_requests_jitter": max_requests_jitter, |
| 931 | "keepalive": keep_alive_timeout, |
| 932 | "registry_ttl_sec": registry_ttl_sec, |
| 933 | } |
| 934 | |
| 935 | # Add SSL options if the paths exist |