This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { exec } from 'node:child_process'; | |
| import os from 'node:os'; | |
| export function getProcessUsage() { | |
| let command = ''; | |
| switch (os.platform()) { | |
| case 'darwin': command = `ps -p ${process.pid} -o %cpu,rss`; break; | |
| case 'linux': command = `ps -p ${process.pid} -o %cpu,rss`; break; | |
| default: return Promise.reject(new Error('Unsupported platform!')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Client } from 'pg'; | |
| import env from 'dotenv'; | |
| // Load .env file. | |
| env.config(); | |
| const connectionURL = process.env.DATABASE_URL; | |
| if (!connectionURL) throw new Error('Missing DATABASE_URL environment variable.'); | |
| const defaultSchemaUrl = connectionURL.replace(/\/[^/]*$/, '/postgres'); |
OlderNewer