mirror of
				https://github.com/TitanEmbeds/Titan.git
				synced 2025-11-04 07:47:10 +01:00 
			
		
		
		
	Use envvar TITAN_GATEWAY_ID to name each gateway workers
This commit is contained in:
		@@ -5,6 +5,7 @@ import functools
 | 
				
			|||||||
from flask import request, session
 | 
					from flask import request, session
 | 
				
			||||||
import time
 | 
					import time
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Gateway(Namespace):
 | 
					class Gateway(Namespace):
 | 
				
			||||||
    def teardown_db_session(self):
 | 
					    def teardown_db_session(self):
 | 
				
			||||||
@@ -12,7 +13,8 @@ class Gateway(Namespace):
 | 
				
			|||||||
        db.session.remove()
 | 
					        db.session.remove()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def on_connect(self):
 | 
					    def on_connect(self):
 | 
				
			||||||
        emit('hello')
 | 
					        gateway_identifier = os.environ.get("TITAN_GATEWAY_ID", None)
 | 
				
			||||||
 | 
					        emit('hello', {"gateway_identifier": gateway_identifier})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def on_identify(self, data):
 | 
					    def on_identify(self, data):
 | 
				
			||||||
        guild_id = data["guild_id"]
 | 
					        guild_id = data["guild_id"]
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2123,6 +2123,14 @@
 | 
				
			|||||||
            process_message_users_cache();
 | 
					            process_message_users_cache();
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        socket.on('hello', function (msg) {
 | 
				
			||||||
 | 
					            var gateway_identifier = msg.gateway_identifier;
 | 
				
			||||||
 | 
					            if (!gateway_identifier) {
 | 
				
			||||||
 | 
					                gateway_identifier = "null";
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            console.log("%c[TitanEmbeds]%cConnected to gateway via%c" + gateway_identifier, 'color:aqua;background-color:black;border:1px solid black;padding: 3px;', 'color:white;background-color:black;border:1px solid black;padding: 3px;', 'color:white;background-color:black;border:1px solid black;font-family: Courier;padding: 3px;');
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        socket.on("disconnect", function () {
 | 
					        socket.on("disconnect", function () {
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user