api/cookie: split initial load into separate function

This commit is contained in:
jj 2024-11-26 14:01:36 +00:00
parent 20074a5091
commit a4cb6ada79
No known key found for this signature in database

View file

@ -62,13 +62,19 @@ const setupWorker = async () => {
cookies = (await cluster.waitFor('cookies')).cookies;
}
export const setup = async (cookiePath) => {
export const loadFromFile = async (path) => {
if (cluster.isPrimary) {
await setupMain(cookiePath);
await setupMain(path);
} else if (cluster.isWorker) {
await setupWorker();
}
dirty = false;
}
export const setup = async (path) => {
await loadFromFile(path);
if (isCluster) {
const messageHandler = (message) => {
if ('cookieUpdate' in message) {