Log binding ip and port
parent: tbd commit: 29408ae
1 | use Error; |
2 | use CacheSubstack; |
3 | use |
4 | , | AuthenticationTokenGranter
5 | |
6 | , DatabaseSettings, UserAuth, RepositoryBackend, UserBackend, | GitBackend
7 | , |
8 | , | client_wrapper
9 | , | DatabaseBackend
10 | ; |
11 | |
12 | use Instance; |
13 | |
14 | use NetworkedSubstack; |
15 | use GiteratedStackBuilder; |
16 | use ; |
17 | use ; |
18 | use |
19 | , | File
20 | , |
21 | , |
22 | , |
23 | ; |
24 | use ; |
25 | use LocalPoolHandle; |
26 | use Table; |
27 | |
28 | |
29 | extern crate tracing; |
30 | |
31 | |
32 | async |
33 | ; | init
34 | let config: Table = |
35 | let mut file = open .await?; |
36 | let mut text = String new; |
37 | file.read_to_string .await?; |
38 | text.parse? |
39 | ; |
40 | let mut listener = bind .await?; |
41 | info!; |
42 | |
43 | let db_conn_options = new |
44 | .host |
45 | .port |
46 | .database |
47 | .username |
48 | .password |
49 | .log_statements; |
50 | let db_pool = connect_with .await?; |
51 | |
52 | debug!; |
53 | ! .run .await?; | migrate
54 | info!; |
55 | |
56 | let stack_cell = new; |
57 | |
58 | let settings = new |
59 | pg_pool: db_pool.clone, |
60 | stack: stack_cell.clone, |
61 | ; |
62 | |
63 | let repository_backend: = |
64 | new |
65 | &db_pool, |
66 | &String from |
67 | config |
68 | .as_str |
69 | .unwrap, |
70 | , |
71 | unwrap, | from_str .
72 | stack_cell.clone, |
73 | ; |
74 | |
75 | let token_granter = new |
76 | config: config.clone, |
77 | instance: from_str .unwrap, |
78 | ; |
79 | |
80 | let user_backend: = new |
81 | db_pool.clone, |
82 | & from_str .unwrap, |
83 | token_granter.clone, |
84 | settings.clone, |
85 | ; |
86 | |
87 | info!; |
88 | |
89 | let database_backend = new |
90 | unwrap, | from_str .
91 | user_backend.clone, |
92 | repository_backend.clone, |
93 | db_pool.clone, |
94 | stack_cell.clone, |
95 | ; |
96 | |
97 | let mut runtime = default; |
98 | |
99 | let database_backend = database_backend.into_substack; |
100 | runtime.merge_builder; |
101 | |
102 | let cache_backend = default; |
103 | runtime.merge_builder; |
104 | |
105 | let networked_stack = NetworkedSubstack |
106 | home_uri: Some |
107 | from_str |
108 | .unwrap |
109 | .0, |
110 | , |
111 | ; |
112 | runtime.merge_builder; |
113 | |
114 | let runtime = runtime.finish; |
115 | |
116 | stack_cell |
117 | .set |
118 | .expect; |
119 | |
120 | let pool = new; |
121 | |
122 | loop |
123 | let stream = accept_stream .await; |
124 | info!; |
125 | |
126 | let = match stream |
127 | Ok => stream, |
128 | Err => |
129 | error!; |
130 | continue; |
131 | |
132 | ; |
133 | |
134 | info!; |
135 | |
136 | let connection = accept_websocket_connection .await; |
137 | |
138 | let connection = match connection |
139 | Ok => connection, |
140 | Err => |
141 | error! |
142 | "Failed to initiate Websocket connection from {}. {:?}", |
143 | address, err |
144 | ; |
145 | continue; |
146 | |
147 | ; |
148 | |
149 | info!; |
150 | |
151 | let our_instance = |
152 | unwrap; | from_str .
153 | let runtime = runtime.clone; |
154 | |
155 | pool.spawn_pinned; |
156 | |
157 | |
158 | |
159 | async |
160 | let stream = listener.accept .await?; |
161 | |
162 | Ok |
163 | |
164 | |
165 | async |
166 | stream: S, |
167 | |
168 | let connection = accept_async .await?; |
169 | |
170 | Ok |
171 | |
172 |