a whole bunch of things
This commit is contained in:
+13
-8
@@ -31,21 +31,26 @@ const mysqlCreds = {
|
||||
// host: '127.0.0.1',
|
||||
// port: 3306,
|
||||
socketPath: '/var/run/mysqld/mysqld.sock',
|
||||
user: 'p42',
|
||||
password: 'C3h=V9!r>Mvc>skxPf9?W2P3duJTk',
|
||||
database: 'p42',
|
||||
user: process.env.mysql_user,
|
||||
password: process.env.mysql_pass,
|
||||
database: 'p42GUI',
|
||||
waitForConnections: true,
|
||||
connectionLimit: 10,
|
||||
queueLimit: 0
|
||||
}
|
||||
|
||||
if(!mysqlCreds.user || !mysqlCreds.password) {
|
||||
console.error('Missing MySQL credentials: set mysql_user and mysql_pass in environment')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const db = await mysql.createConnection(mysqlCreds)
|
||||
|
||||
const sessionStore = new MySQLStore({
|
||||
createDatabaseTable: false,
|
||||
clearExpired: true,
|
||||
schema: {
|
||||
tableName: 'p42_sessions',
|
||||
tableName: 'sessions',
|
||||
columnNames: {
|
||||
session_id: 'session_id',
|
||||
expires: 'expires',
|
||||
@@ -84,12 +89,12 @@ async function startAllRedis(wssGatewayConfig) {
|
||||
)
|
||||
const loginResults = await Promise.allSettled(
|
||||
redisConns.map(async cnx => {
|
||||
cnx.redisLogin()
|
||||
await cnx.redisLogin()
|
||||
return cnx.redisId
|
||||
})
|
||||
)
|
||||
|
||||
2. //make sure all connected before going any further
|
||||
//2. make sure all connected before going any further
|
||||
const failedLogin = loginResults.filter(r => r.status !== 'fulfilled')
|
||||
if (failedLogin.length > 0) {
|
||||
console.error('Redis login failures:')
|
||||
@@ -107,7 +112,7 @@ async function startAllRedis(wssGatewayConfig) {
|
||||
// --- Phase 2: start channels for all (since all succeeded)
|
||||
const chanResults = await Promise.allSettled(
|
||||
redisConns.map(async cnx => {
|
||||
cnx.redisChansStart()
|
||||
await cnx.redisChansStart()
|
||||
return cnx.redisId
|
||||
})
|
||||
)
|
||||
@@ -172,7 +177,7 @@ cfgh.fetchConfig().then( async wssGatewayConfig => {
|
||||
return
|
||||
}
|
||||
WSSServer.handleUpgrade(req, socket, head, (ws) => {
|
||||
ws.session = req.session // direct access to Express session
|
||||
ws.session = req.session // Caution : that one is turned in stone, not alive !
|
||||
WSSServer.emit('connection', ws, req)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user