Skip to content

Instantly share code, notes, and snippets.

@Goopil
Goopil / prom-client_pm2_cluster.js
Created August 11, 2023 18:47 — forked from yekver/prom-client_pm2_cluster.js
Instead of `cluster` module there is no direct access to the master process in `pm2`. To return metrics for the whole cluster you can do IPC calls from the active instance to the rest of them and wait while all their locally collected metrics will be sent. Finally you have to aggregate all received metrics.
const prom = require('prom-client');
const pm2 = require('pm2');
let pm2Bus;
const REQ_TOPIC = 'get_prom_register';
function pm2exec(cmd, ...args) {
return new Promise((resolve, reject) => {
pm2[cmd](...args, (err, resp) => (err ? reject(err) : resolve(resp)));
@Goopil
Goopil / App.vue
Created November 30, 2016 19:07
map Mappers & and collections from js-data datastore to vue instance
<template>
...
</template>
<script>
import { mapCollections, mapMappers } from './plugins/jsData'
export default {
name: 'app',
computed () {
...mapCollections([