mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-24 09:14:46 +01:00
parent
ec0ec261bc
commit
426f93030d
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,5 +1,7 @@
|
||||
.idea
|
||||
.clinic
|
||||
node_modules
|
||||
node_modules/
|
||||
yarn-error.log
|
||||
dist
|
||||
dist/
|
||||
.yalc/
|
||||
yalc.lock
|
||||
|
@ -78,7 +78,7 @@ export class Worker extends Base {
|
||||
|
||||
return () => {
|
||||
const result = this.broker.subscribe(queue, onMessage)
|
||||
console.info(`✅ Celery worker subscribed to ${Object.keys(this.handlers).join(', ')}`)
|
||||
console.info(`✅ Celery worker subscribed to ${Object.keys(this.handlers).join(', ')}!`)
|
||||
return result
|
||||
}
|
||||
}
|
||||
@ -184,14 +184,14 @@ export class Worker extends Base {
|
||||
console.info(
|
||||
`⌛ ${taskCount} ${taskCount === 1 ? 'task' : 'tasks'} in progress, waiting for ${
|
||||
taskCount === 1 ? 'it' : 'them'
|
||||
} to finish before cleaning Celery up...`
|
||||
} to finish before disconnecting Celery...`
|
||||
)
|
||||
await this.whenCurrentJobsFinished()
|
||||
} else {
|
||||
console.info(`👍 No tasks in progress, cleaning Celery up...`)
|
||||
console.info(`👍 No tasks in progress, disconnecting Celery...`)
|
||||
}
|
||||
await this.disconnect()
|
||||
console.info(`🛑 Celery worker cleaned up!`)
|
||||
console.info(`🛑 Celery worker disconnected!`)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ async function loadPlugin(server: PluginsServer, pluginConfig: PluginConfig): Pr
|
||||
|
||||
try {
|
||||
pluginConfig.vm = createPluginConfigVM(server, pluginConfig, indexJs, libJs)
|
||||
console.log(`Loaded local plugin "${plugin.name}" from "${pluginPath}"!`)
|
||||
console.info(`Loaded local plugin "${plugin.name}" from "${pluginPath}"!`)
|
||||
await clearError(server, pluginConfig)
|
||||
return true
|
||||
} catch (error) {
|
||||
|
@ -114,7 +114,7 @@ export async function startPluginsServer(
|
||||
pubSub.subscribe(server.PLUGINS_RELOAD_PUBSUB_CHANNEL)
|
||||
pubSub.on('message', async (channel, message) => {
|
||||
if (channel === server!.PLUGINS_RELOAD_PUBSUB_CHANNEL) {
|
||||
console.log('⚡ Reloading plugins!')
|
||||
console.info('⚡ Reloading plugins!')
|
||||
await queue?.stop()
|
||||
await stopPiscina(piscina!)
|
||||
piscina = makePiscina(serverConfig!)
|
||||
|
@ -7,7 +7,7 @@ export function buildFastifyInstance(): FastifyInstance {
|
||||
|
||||
export async function stopFastifyInstance(fastifyInstance: FastifyInstance): Promise<void> {
|
||||
await fastifyInstance.close()
|
||||
console.info(`🛑 Web server cleaned up!`)
|
||||
console.info(`🛑 Web server closed!`)
|
||||
}
|
||||
|
||||
export async function startFastifyInstance(
|
||||
|
@ -1,6 +1,6 @@
|
||||
const Sentry = require('@sentry/node')
|
||||
|
||||
const { isMainThread } = require('worker_threads')
|
||||
const { isMainThread, threadId } = require('worker_threads')
|
||||
|
||||
if (isMainThread) {
|
||||
const Piscina = require('piscina')
|
||||
@ -10,7 +10,7 @@ if (isMainThread) {
|
||||
const piscina = new Piscina(createConfig(serverConfig, __filename))
|
||||
piscina.on('error', (error) => {
|
||||
Sentry.captureException(error)
|
||||
console.error('🔴 Piscina Worker Error!')
|
||||
console.error(`⚠️ Piscina worker thread ${threadId} error!`)
|
||||
console.error(error)
|
||||
})
|
||||
return piscina
|
||||
@ -23,7 +23,7 @@ if (isMainThread) {
|
||||
|
||||
const { createWorker } = require('./worker')
|
||||
const { workerData } = require('piscina')
|
||||
module.exports = createWorker(workerData.serverConfig)
|
||||
module.exports = createWorker(workerData.serverConfig, threadId)
|
||||
}
|
||||
|
||||
function areWeTestingWithJest() {
|
||||
|
@ -6,8 +6,8 @@ import { initApp } from '../init'
|
||||
|
||||
type TaskWorker = ({ task, args }: { task: string; args: any }) => Promise<any>
|
||||
|
||||
export async function createWorker(config: PluginsServerConfig): Promise<TaskWorker> {
|
||||
console.info('🧵 Starting Piscina Worker Thread')
|
||||
export async function createWorker(config: PluginsServerConfig, threadId: number): Promise<TaskWorker> {
|
||||
console.info(`🧵 Starting Piscina worker thread ${threadId}…`)
|
||||
|
||||
initApp(config)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user