Huge refactor to prep for moving the daemon over to the plugin architecture
parent: tbd commit: 5df753c
1 | use Error; |
2 | use ; |
3 | |
4 | use Instance; |
5 | |
6 | use Runtime; |
7 | use NetworkedSubstack; |
8 | use ; |
9 | use ; |
10 | use |
11 | , | File
12 | , |
13 | , |
14 | , |
15 | ; |
16 | use ; |
17 | use LocalPoolHandle; |
18 | use Table; |
19 | |
20 | |
21 | extern crate tracing; |
22 | |
23 | |
24 | async |
25 | ; | init
26 | let config: Table = |
27 | let mut file = open .await?; |
28 | let mut text = String new; |
29 | file.read_to_string .await?; |
30 | text.parse? |
31 | ; |
32 | let mut listener = bind .await?; |
33 | let db_conn_options = new |
34 | .host |
35 | .port |
36 | .database |
37 | .username |
38 | .password |
39 | .log_statements; |
40 | let db_pool = connect_with .await?; |
41 | |
42 | debug!; |
43 | ! .run .await?; | migrate
44 | info!; |
45 | |
46 | let token_granter = new |
47 | config: config.clone, |
48 | instance: from_str .unwrap, |
49 | ; |
50 | |
51 | info!; |
52 | |
53 | let mut runtime = default; |
54 | |
55 | let networked_stack = NetworkedSubstack |
56 | home_uri: Some |
57 | from_str |
58 | .unwrap |
59 | .0, |
60 | , |
61 | ; |
62 | |
63 | let runtime = new; |
64 | |
65 | let pool = new; |
66 | |
67 | loop |
68 | let stream = accept_stream .await; |
69 | info!; |
70 | |
71 | let = match stream |
72 | Ok => stream, |
73 | Err => |
74 | error!; |
75 | continue; |
76 | |
77 | ; |
78 | |
79 | info!; |
80 | |
81 | let connection = accept_websocket_connection .await; |
82 | |
83 | let connection = match connection |
84 | Ok => connection, |
85 | Err => |
86 | error! |
87 | "Failed to initiate Websocket connection from {}. {:?}", |
88 | address, err |
89 | ; |
90 | continue; |
91 | |
92 | ; |
93 | |
94 | info!; |
95 | |
96 | let our_instance = |
97 | unwrap; | from_str .
98 | let runtime = runtime.clone; |
99 | |
100 | pool.spawn_pinned; |
101 | |
102 | |
103 | |
104 | async |
105 | let stream = listener.accept .await?; |
106 | |
107 | Ok |
108 | |
109 | |
110 | async |
111 | stream: S, |
112 | |
113 | let connection = accept_async .await?; |
114 | |
115 | Ok |
116 | |
117 |