-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (25 loc) · 768 Bytes
/
main.py
File metadata and controls
33 lines (25 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import logging
from pyftpdlib.servers import FTPServer
from config.base import (
DEBUG,
FTP_MAX_CONNECTIONS,
FTP_MAX_CONNECTIONS_PER_IP,
FTP_PORT,
FTP_WORKER_COUNT,
)
from openspp_dms_ftp_server.handlers import OPENSPPHandler
def main() -> None:
"""
Main entrypoint to the server.
:return:
"""
address = ("0.0.0.0", FTP_PORT)
server = FTPServer(address, OPENSPPHandler)
log_level = logging.DEBUG if DEBUG else logging.INFO
logging.basicConfig(level=log_level)
# set a limit for connections
server.max_cons = FTP_MAX_CONNECTIONS
server.max_cons_per_ip = FTP_MAX_CONNECTIONS_PER_IP
server.serve_forever(handle_exit=True, worker_processes=FTP_WORKER_COUNT)
if __name__ == "__main__":
main()