@milaboratories/pl-deployments 2.4.7 → 2.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/common/os_and_arch.cjs +39 -0
  2. package/dist/common/os_and_arch.cjs.map +1 -0
  3. package/dist/common/os_and_arch.d.ts +0 -1
  4. package/dist/common/os_and_arch.js +34 -0
  5. package/dist/common/os_and_arch.js.map +1 -0
  6. package/dist/common/pl_binary.cjs +34 -0
  7. package/dist/common/pl_binary.cjs.map +1 -0
  8. package/dist/common/pl_binary.d.ts +0 -1
  9. package/dist/common/pl_binary.js +30 -0
  10. package/dist/common/pl_binary.js.map +1 -0
  11. package/dist/common/pl_binary_download.cjs +172 -0
  12. package/dist/common/pl_binary_download.cjs.map +1 -0
  13. package/dist/common/pl_binary_download.d.ts +0 -1
  14. package/dist/common/pl_binary_download.js +148 -0
  15. package/dist/common/pl_binary_download.js.map +1 -0
  16. package/dist/common/pl_version.cjs +11 -0
  17. package/dist/common/pl_version.cjs.map +1 -0
  18. package/dist/common/pl_version.d.ts +0 -1
  19. package/dist/common/pl_version.js +9 -0
  20. package/dist/common/pl_version.js.map +1 -0
  21. package/dist/index.cjs +26 -0
  22. package/dist/index.cjs.map +1 -0
  23. package/dist/index.d.ts +0 -1
  24. package/dist/index.js +5 -64
  25. package/dist/index.js.map +1 -1
  26. package/dist/local/options.d.ts +0 -1
  27. package/dist/local/pid.cjs +24 -0
  28. package/dist/local/pid.cjs.map +1 -0
  29. package/dist/local/pid.d.ts +0 -1
  30. package/dist/local/pid.js +20 -0
  31. package/dist/local/pid.js.map +1 -0
  32. package/dist/local/pl.cjs +223 -0
  33. package/dist/local/pl.cjs.map +1 -0
  34. package/dist/local/pl.d.ts +0 -1
  35. package/dist/local/pl.js +198 -0
  36. package/dist/local/pl.js.map +1 -0
  37. package/dist/local/process.cjs +77 -0
  38. package/dist/local/process.cjs.map +1 -0
  39. package/dist/local/process.d.ts +1 -2
  40. package/dist/local/process.js +72 -0
  41. package/dist/local/process.js.map +1 -0
  42. package/dist/local/trace.cjs +27 -0
  43. package/dist/local/trace.cjs.map +1 -0
  44. package/dist/local/trace.d.ts +0 -1
  45. package/dist/local/trace.js +23 -0
  46. package/dist/local/trace.js.map +1 -0
  47. package/dist/package.json.cjs +7 -0
  48. package/dist/package.json.cjs.map +1 -0
  49. package/dist/package.json.js +5 -0
  50. package/dist/package.json.js.map +1 -0
  51. package/dist/ssh/__tests__/common-utils.d.ts +0 -1
  52. package/dist/ssh/connection_info.cjs +62 -0
  53. package/dist/ssh/connection_info.cjs.map +1 -0
  54. package/dist/ssh/connection_info.d.ts +0 -1
  55. package/dist/ssh/connection_info.js +55 -0
  56. package/dist/ssh/connection_info.js.map +1 -0
  57. package/dist/ssh/pl.cjs +500 -0
  58. package/dist/ssh/pl.cjs.map +1 -0
  59. package/dist/ssh/pl.d.ts +0 -1
  60. package/dist/ssh/pl.js +497 -0
  61. package/dist/ssh/pl.js.map +1 -0
  62. package/dist/ssh/pl_paths.cjs +67 -0
  63. package/dist/ssh/pl_paths.cjs.map +1 -0
  64. package/dist/ssh/pl_paths.d.ts +0 -1
  65. package/dist/ssh/pl_paths.js +50 -0
  66. package/dist/ssh/pl_paths.js.map +1 -0
  67. package/dist/ssh/ssh.cjs +621 -0
  68. package/dist/ssh/ssh.cjs.map +1 -0
  69. package/dist/ssh/ssh.d.ts +0 -1
  70. package/dist/ssh/ssh.js +619 -0
  71. package/dist/ssh/ssh.js.map +1 -0
  72. package/dist/ssh/supervisord.cjs +149 -0
  73. package/dist/ssh/supervisord.cjs.map +1 -0
  74. package/dist/ssh/supervisord.d.ts +0 -1
  75. package/dist/ssh/supervisord.js +140 -0
  76. package/dist/ssh/supervisord.js.map +1 -0
  77. package/package.json +16 -14
  78. package/src/common/pl_version.ts +3 -2
  79. package/src/local/pl.ts +6 -1
  80. package/src/local/process.ts +40 -3
  81. package/dist/common/os_and_arch.d.ts.map +0 -1
  82. package/dist/common/pl_binary.d.ts.map +0 -1
  83. package/dist/common/pl_binary_download.d.ts.map +0 -1
  84. package/dist/common/pl_version.d.ts.map +0 -1
  85. package/dist/index.d.ts.map +0 -1
  86. package/dist/index.mjs +0 -1366
  87. package/dist/index.mjs.map +0 -1
  88. package/dist/local/options.d.ts.map +0 -1
  89. package/dist/local/pid.d.ts.map +0 -1
  90. package/dist/local/pl.d.ts.map +0 -1
  91. package/dist/local/process.d.ts.map +0 -1
  92. package/dist/local/trace.d.ts.map +0 -1
  93. package/dist/ssh/__tests__/common-utils.d.ts.map +0 -1
  94. package/dist/ssh/connection_info.d.ts.map +0 -1
  95. package/dist/ssh/pl.d.ts.map +0 -1
  96. package/dist/ssh/pl_paths.d.ts.map +0 -1
  97. package/dist/ssh/ssh.d.ts.map +0 -1
  98. package/dist/ssh/supervisord.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ssh.js","sources":["../../src/ssh/ssh.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-misused-promises */\n/* eslint-disable @typescript-eslint/no-base-to-string */\nimport type { ConnectConfig, ClientChannel, SFTPWrapper } from 'ssh2';\nimport ssh, { Client } from 'ssh2';\nimport net from 'node:net';\nimport dns from 'node:dns';\nimport fs from 'node:fs';\nimport { readFile } from 'node:fs/promises';\nimport upath from 'upath';\nimport { RetryablePromise, type MiLogger } from '@milaboratories/ts-helpers';\nimport { randomBytes } from 'node:crypto';\n\nconst defaultConfig: ConnectConfig = {\n keepaliveInterval: 60000,\n keepaliveCountMax: 10,\n};\n\nexport type SshAuthMethods = 'publickey' | 'password';\nexport type SshAuthMethodsResult = SshAuthMethods[];\nexport type SshDirContent = {\n files: string[];\n directories: string[];\n};\n\nexport class SshClient {\n private config?: ConnectConfig;\n public homeDir?: string;\n private forwardedServers: net.Server[] = [];\n\n constructor(\n private readonly logger: MiLogger,\n private readonly client: Client,\n ) {}\n\n /**\n * Initializes the SshClient and establishes a connection using the provided configuration.\n * @param config - The connection configuration object for the SSH client.\n * @returns A new instance of SshClient with an active connection.\n */\n public static async init(logger: MiLogger, config: ConnectConfig): Promise<SshClient> {\n const withDefaults = {\n ...defaultConfig,\n ...config,\n };\n\n const client = new SshClient(logger, new Client());\n await client.connect(withDefaults);\n\n return client;\n }\n\n public getForwardedServers() {\n return this.forwardedServers;\n }\n\n public getFullHostName() {\n return `${this.config?.host}:${this.config?.port}`;\n }\n\n public getUserName() {\n return this.config?.username;\n }\n\n /**\n * Connects to the SSH server using the specified configuration.\n * @param config - The connection configuration object for the SSH client.\n * @returns A promise that resolves when the connection is established or rejects on error.\n */\n public async connect(config: ConnectConfig) {\n this.config = config;\n return await connect(this.client, config, () => {}, () => {});\n }\n\n /**\n * Executes a command on the SSH server.\n * @param command - The command to execute on the remote server.\n * @returns A promise resolving with the command's stdout and stderr outputs.\n */\n public async exec(command: string): Promise<SshExecResult> {\n return new Promise((resolve, reject) => {\n this.client.exec(command, (err: any, stream: ClientChannel) => {\n if (err) {\n return reject(new Error(`ssh.exec: ${command}: ${err}`));\n }\n\n let stdout = '';\n let stderr = '';\n\n stream.on('close', (code: number) => {\n if (code === 0) {\n resolve({ stdout, stderr });\n } else {\n reject(new Error(`Command ${command} exited with code ${code}, stdout: ${stdout}, stderr: ${stderr}`));\n }\n }).on('data', (data: ArrayBuffer) => {\n stdout += data.toString();\n }).stderr.on('data', (data: ArrayBuffer) => {\n stderr += data.toString();\n });\n });\n });\n }\n\n /**\n * Retrieves the supported authentication methods for a given host and port.\n * @param host - The hostname or IP address of the server.\n * @param port - The port number to connect to on the server.\n * @returns 'publickey' | 'password'[] A promise resolving with a list of supported authentication methods.\n */\n public static async getAuthTypes(host: string, port: number): Promise<SshAuthMethodsResult> {\n return new Promise((resolve) => {\n let stdout = '';\n const conn = new Client();\n\n conn.on('ready', () => {\n conn.end();\n const types = this.extractAuthMethods(stdout);\n resolve(types.length === 0 ? ['publickey', 'password'] : types as SshAuthMethodsResult);\n });\n\n conn.on('error', () => {\n conn.end();\n resolve(['publickey', 'password']);\n });\n\n conn.connect({\n host,\n port,\n username: new Date().getTime().toString(),\n debug: (err) => {\n stdout += `${err}\\n`;\n },\n });\n });\n }\n\n /**\n * Extracts authentication methods from debug logs.\n * @param log - The debug log output containing authentication information.\n * @returns An array of extracted authentication methods.\n */\n private static extractAuthMethods(log: string): string[] {\n const match = log.match(/Inbound: Received USERAUTH_FAILURE \\((.+)\\)/);\n return match && match[1] ? match[1].split(',').map((method) => method.trim()) : [];\n }\n\n /**\n * Sets up port forwarding between a remote port on the SSH server and a local port.\n * A new connection is used for this operation instead of an existing one.\n * @param ports - An object specifying the remote and local port configuration.\n * @param config - Optional connection configuration for the SSH client.\n * @returns { server: net.Server } A promise resolving with the created server instance.\n */\n public async forwardPort(ports: { remotePort: number; localPort: number; localHost?: string }, config?: ConnectConfig): Promise<{ server: net.Server }> {\n const log = `ssh.forward:${ports.localPort}:${ports.remotePort}.id_${randomBytes(1).toString('hex')}`;\n config = config ?? this.config;\n\n // we make this thing persistent so that if the connection\n // drops (it happened in the past because of lots of errors and forwardOut opened channels),\n // we'll recreate it here.\n const persistentClient = new RetryablePromise((p: RetryablePromise<Client>) => {\n return new Promise<Client>((resolve, reject) => {\n const client = new Client();\n\n client.on('ready', () => {\n this.logger.info(`${log}.client.ready`);\n resolve(client);\n });\n\n client.on('error', (err) => {\n this.logger.info(`${log}.client.error: ${err}`);\n p.reset();\n reject(err);\n });\n\n client.on('close', () => {\n this.logger.info(`${log}.client.closed`);\n p.reset();\n });\n\n client.connect(config!);\n });\n });\n\n await persistentClient.ensure(); // warm up a connection\n\n return new Promise((resolve, reject) => {\n const server = net.createServer({ pauseOnConnect: true }, async (localSocket) => {\n const sockLog = `${log}.sock_${randomBytes(1).toString('hex')}`;\n // this.logger.info(`${sockLog}.localSocket: start connection`);\n let conn: Client;\n try {\n conn = await persistentClient.ensure();\n } catch (e: unknown) {\n this.logger.info(`${sockLog}.persistentClient.catch: ${e}`);\n localSocket.end();\n return;\n }\n\n // Remove TCP buffering.\n // Although it means less throughput (bad), it also less latency (good).\n // It could help when we have\n // small messages like in our grpc transactions.\n // And it also could help when we have tcp forwarding to not buffer messages in the middle.\n (conn as any).setNoDelay(true);\n localSocket.setNoDelay(true);\n\n let stream: ClientChannel;\n try {\n stream = await forwardOut(this.logger, conn, '127.0.0.1', 0, '127.0.0.1', ports.remotePort);\n } catch (e: unknown) {\n this.logger.error(`${sockLog}.forwardOut.err: ${e}`);\n localSocket.end();\n return;\n }\n\n localSocket.pipe(stream);\n stream.pipe(localSocket);\n localSocket.resume();\n // this.logger.info(`${sockLog}.forwardOut: connected`);\n\n stream.on('error', (err: unknown) => {\n this.logger.error(`${sockLog}.stream.error: ${err}`);\n localSocket.end();\n stream.end();\n });\n stream.on('close', () => {\n // this.logger.info(`${sockLog}.stream.close: closed`);\n localSocket.end();\n stream.end();\n });\n localSocket.on('close', () => {\n this.logger.info(`${sockLog}.localSocket: closed`);\n localSocket.end();\n stream.end();\n });\n });\n\n server.listen(ports.localPort, '127.0.0.1', () => {\n this.logger.info(`${log}.server: started listening`);\n this.forwardedServers.push(server);\n resolve({ server });\n });\n\n server.on('error', (err) => {\n server.close();\n reject(new Error(`${log}.server: error: ${JSON.stringify(err)}`));\n });\n\n server.on('close', () => {\n this.logger.info(`${log}.server: closed ${JSON.stringify(ports)}`);\n this.forwardedServers = this.forwardedServers.filter((s) => s !== server);\n });\n });\n }\n\n public closeForwardedPorts(): void {\n this.logger.info('[SSH] Closing all forwarded ports...');\n this.forwardedServers.forEach((server) => {\n const rawAddress = server.address();\n if (rawAddress && typeof rawAddress !== 'string') {\n const address: net.AddressInfo = rawAddress;\n this.logger.info(`[SSH] Closing port forward for server ${address.address}:${address.port}`);\n }\n\n server.close();\n });\n this.forwardedServers = [];\n }\n\n /**\n * Checks if a specified host is available by performing a DNS lookup.\n * @param hostname - The hostname or IP address to check.\n * @returns A promise resolving with `true` if the host is reachable, otherwise `false`.\n */\n public static async checkHostAvailability(hostname: string): Promise<boolean> {\n return new Promise((resolve) => {\n dns.lookup(hostname, (err) => {\n resolve(!err);\n });\n });\n }\n\n /**\n * Determines whether a private key requires a passphrase for use.\n * @param privateKey - The private key content to check.\n * @returns A promise resolving with `true` if a passphrase is required, otherwise `false`.\n */\n public static async isPassphraseRequiredForKey(privateKey: string): Promise<boolean> {\n return new Promise((resolve, reject) => {\n try {\n const keyOrError = ssh.utils.parseKey(privateKey);\n if (keyOrError instanceof Error) {\n resolve(true);\n }\n return resolve(false);\n } catch (err: unknown) {\n console.log('Error parsing privateKey');\n reject(new Error(`ssh.isPassphraseRequiredForKey: err ${err}`));\n }\n });\n }\n\n /**\n * Uploads a local file to a remote server via SFTP.\n * This function creates new SFTP connection\n * @param localPath - The local file path.\n * @param remotePath - The remote file path on the server.\n * @returns A promise resolving with `true` if the file was successfully uploaded.\n */\n public async uploadFile(localPath: string, remotePath: string): Promise<boolean> {\n return await this.withSftp(async (sftp) => {\n return new Promise((resolve, reject) => {\n sftp.fastPut(localPath, remotePath, (err) => {\n if (err) {\n const newErr = new Error(\n `ssh.uploadFile: err: ${err}, localPath: ${localPath}, remotePath: ${remotePath}`);\n return reject(newErr);\n }\n resolve(true);\n });\n });\n });\n }\n\n public async withSftp<R>(callback: (sftp: SFTPWrapper) => Promise<R>): Promise<R> {\n return new Promise((resolve, reject) => {\n this.client.sftp((err, sftp) => {\n if (err) {\n return reject(new Error(`ssh.withSftp: sftp err: ${err}`));\n }\n\n callback(sftp)\n .then(resolve)\n .catch((err) => {\n reject(new Error(`ssh.withSftp.callback: err ${err}`));\n })\n .finally(() => {\n sftp?.end();\n });\n });\n });\n }\n\n public async writeFileOnTheServer(remotePath: string, data: string | Buffer, mode: number = 0o660) {\n return this.withSftp(async (sftp) => {\n return this.writeFile(sftp, remotePath, data, mode);\n });\n }\n\n public async getForderStructure(sftp: SFTPWrapper, remotePath: string, data: SshDirContent = { files: [], directories: [] }): Promise<SshDirContent> {\n return new Promise((resolve, reject) => {\n sftp.readdir(remotePath, async (err, items) => {\n if (err) {\n return reject(err);\n }\n\n for (const item of items) {\n const itemPath = `${remotePath}/${item.filename}`;\n if (item.attrs.isDirectory()) {\n data.directories.push(itemPath);\n try {\n await this.getForderStructure(sftp, itemPath, data);\n } catch (error) {\n return reject(error instanceof Error ? error : new Error(String(error)));\n }\n } else {\n data.files.push(itemPath);\n }\n }\n resolve(data);\n });\n });\n }\n\n public rmdir(sftp: SFTPWrapper, path: string) {\n return new Promise((resolve, reject) => {\n sftp.rmdir(path, (err) => err ? reject(err) : resolve(true));\n });\n }\n\n public unlink(sftp: SFTPWrapper, path: string) {\n return new Promise((resolve, reject) => {\n sftp.unlink(path, (err) => err ? reject(err) : resolve(true));\n });\n }\n\n public async deleteFolder(path: string) {\n return this.withSftp(async (sftp) => {\n try {\n const list = await this.getForderStructure(sftp, path);\n this.logger.info(`ssh.deleteFolder list of files and directories`);\n this.logger.info(`ssh.deleteFolder list of files: ${list.files}`);\n this.logger.info(`ssh.deleteFolder list of directories: ${list.directories}`);\n\n for (const filePath of list.files) {\n this.logger.info(`ssh.deleteFolder unlink file ${filePath}`);\n await this.unlink(sftp, filePath);\n }\n\n list.directories.sort((a, b) => b.length - a.length);\n\n for (const directoryPath of list.directories) {\n this.logger.info(`ssh.deleteFolder rmdir ${directoryPath}`);\n await this.rmdir(sftp, directoryPath);\n }\n\n await this.rmdir(sftp, path);\n return true;\n } catch (e: unknown) {\n this.logger.error(e);\n const message = e instanceof Error ? e.message : '';\n throw new Error(`ssh.deleteFolder: path: ${path}, message: ${message}`);\n }\n });\n }\n\n public async readFile(remotePath: string): Promise<string> {\n return this.withSftp(async (sftp) => {\n return new Promise((resolve, reject) => {\n sftp.readFile(remotePath, (err, buffer) => {\n if (err) {\n return reject(new Error(`ssh.readFile: ${err}`));\n }\n resolve(buffer.toString());\n });\n });\n });\n }\n\n async chmod(path: string, mode: number) {\n return this.withSftp(async (sftp) => {\n return new Promise((resolve, reject) => {\n sftp.chmod(path, mode, (err) => {\n if (err) {\n return reject(new Error(`ssh.chmod: ${err}, path: ${path}, mode: ${mode}`));\n }\n return resolve(undefined);\n });\n });\n });\n }\n\n async checkFileExists(remotePath: string) {\n return this.withSftp(async (sftp) => {\n return new Promise((resolve, reject) => {\n sftp.stat(remotePath, (err: Error | undefined, stats) => {\n if (err) {\n if ((err as unknown as { code?: number })?.code === 2) {\n return resolve(false);\n }\n return reject(new Error(`ssh.checkFileExists: err ${err}`));\n }\n resolve(stats.isFile());\n });\n });\n });\n }\n\n async checkPathExists(remotePath: string): Promise<{ exists: boolean; isFile: boolean; isDirectory: boolean }> {\n return this.withSftp(async (sftp) => {\n return new Promise((resolve, reject) => {\n sftp.stat(remotePath, (err, stats) => {\n if (err) {\n if ((err as Error & { code: number }).code === 2) {\n return resolve({ exists: false, isFile: false, isDirectory: false });\n }\n return reject(new Error(`ssh.checkPathExists: ${err}`));\n }\n resolve({\n exists: true,\n isFile: stats.isFile(),\n isDirectory: stats.isDirectory(),\n });\n });\n });\n });\n }\n\n private async writeFile(sftp: SFTPWrapper, remotePath: string, data: string | Buffer, mode: number = 0o660): Promise<boolean> {\n return new Promise((resolve, reject) => {\n sftp.writeFile(remotePath, data, { mode }, (err) => {\n if (err) {\n return reject(new Error(`ssh.writeFile: err ${err}, remotePath: ${remotePath}`));\n }\n resolve(true);\n });\n });\n }\n\n public uploadFileUsingExistingSftp(sftp: SFTPWrapper, localPath: string, remotePath: string, mode: number = 0o660) {\n return new Promise((resolve, reject) => {\n void readFile(localPath).then(async (result: Buffer) => {\n return this.writeFile(sftp, remotePath, result, mode)\n .then(() => {\n resolve(undefined);\n })\n .catch((err) => {\n const msg = `uploadFileUsingExistingSftp: ${err}`;\n this.logger.error(msg);\n reject(new Error(msg));\n });\n });\n });\n }\n\n private async __uploadDirectory(sftp: SFTPWrapper, localDir: string, remoteDir: string, mode: number = 0o660): Promise<void> {\n return new Promise((resolve, reject) => {\n fs.readdir(localDir, async (err, files) => {\n if (err) {\n return reject(new Error(`ssh.__uploadDir: err ${err}, localDir: ${localDir}, remoteDir: ${remoteDir}`));\n }\n\n try {\n await this.__createRemoteDirectory(sftp, remoteDir);\n for (const file of files) {\n const localPath = upath.join(localDir, file);\n const remotePath = `${remoteDir}/${file}`;\n\n if (fs.lstatSync(localPath).isDirectory()) {\n await this.__uploadDirectory(sftp, localPath, remotePath, mode);\n } else {\n await this.uploadFileUsingExistingSftp(sftp, localPath, remotePath, mode);\n }\n }\n\n resolve();\n } catch (err) {\n const msg = `ssh.__uploadDir: catched err ${err}`;\n this.logger.error(msg);\n reject(new Error(msg));\n }\n });\n });\n }\n\n /**\n * Uploads a local directory and its contents (including subdirectories) to the remote server via SFTP.\n * @param localDir - The path to the local directory to upload.\n * @param remoteDir - The path to the remote directory on the server.\n * @returns A promise that resolves when the directory and its contents are uploaded.\n */\n public async uploadDirectory(localDir: string, remoteDir: string, mode: number = 0o660): Promise<void> {\n return new Promise((resolve, reject) => {\n void this.withSftp(async (sftp: SFTPWrapper) => {\n try {\n await this.__uploadDirectory(sftp, localDir, remoteDir, mode);\n resolve();\n } catch (e: unknown) {\n reject(new Error(`ssh.uploadDirectory: ${e}`));\n }\n });\n });\n }\n\n /**\n * Ensures that a remote directory and all its parent directories exist.\n * @param sftp - The SFTP wrapper.\n * @param remotePath - The path to the remote directory.\n * @returns A promise that resolves when the directory is created.\n */\n private __createRemoteDirectory(sftp: SFTPWrapper, remotePath: string): Promise<void> {\n return new Promise((resolve, reject) => {\n const directories = remotePath.split('/');\n let currentPath = '';\n\n const createNext = (index: number) => {\n if (index >= directories.length) {\n return resolve();\n }\n\n currentPath += `${directories[index]}/`;\n\n sftp.stat(currentPath, (err) => {\n if (err) {\n sftp.mkdir(currentPath, (err) => {\n if (err) {\n return reject(new Error(`ssh.__createRemDir: err ${err}, remotePath: ${remotePath}`));\n }\n createNext(index + 1);\n });\n } else {\n createNext(index + 1);\n }\n });\n };\n\n createNext(0);\n });\n }\n\n /**\n * Ensures that a remote directory and all its parent directories exist.\n * @param sftp - The SFTP wrapper.\n * @param remotePath - The path to the remote directory.\n * @returns A promise that resolves when the directory is created.\n */\n public ensureRemoteDirCreated(remotePath: string, mode: number = 0o755): Promise<void> {\n return this.withSftp(async (sftp) => {\n const directories = remotePath.split('/');\n let currentPath = '';\n\n for (const directory of directories) {\n currentPath += `${directory}/`;\n\n try {\n await new Promise<void>((resolve, reject) => {\n sftp.stat(currentPath, (err) => {\n if (!err) return resolve();\n\n sftp.mkdir(currentPath, { mode }, (err) => {\n if (err) {\n return reject(new Error(`ssh.createRemoteDir: err ${err}, remotePath: ${remotePath}`));\n }\n resolve();\n });\n });\n });\n } catch (error) {\n console.error(`Failed to create directory: ${currentPath}`, error);\n throw error;\n }\n }\n });\n }\n\n /**\n * Downloads a file from the remote server to a local path via SFTP.\n * @param remotePath - The remote file path on the server.\n * @param localPath - The local file path to save the file.\n * @returns A promise resolving with `true` if the file was successfully downloaded.\n */\n public async downloadFile(remotePath: string, localPath: string): Promise<boolean> {\n return this.withSftp(async (sftp) => {\n return new Promise((resolve, reject) => {\n sftp.fastGet(remotePath, localPath, (err) => {\n if (err) {\n return reject(new Error(`ssh.downloadFile: err ${err}, remotePath: ${remotePath}, localPath: ${localPath}`));\n }\n resolve(true);\n });\n });\n });\n }\n\n /**\n * Closes the SSH client connection and forwarded ports.\n */\n public close(): void {\n this.closeForwardedPorts();\n this.client.end();\n }\n}\n\nexport type SshExecResult = { stdout: string; stderr: string };\n\nasync function connect(\n client: Client,\n config: ConnectConfig,\n onError: (e: unknown) => void,\n onClose: () => void,\n): Promise<Client> {\n return new Promise((resolve, reject) => {\n client.on('ready', () => {\n resolve(client);\n });\n\n client.on('error', (err: unknown) => {\n onError(err);\n reject(new Error(`ssh.connect: ${err}`));\n });\n\n client.on('close', () => {\n onClose();\n });\n\n client.connect(config);\n\n // Remove TCP buffering.\n // Although it means less throughput (bad), it also means less latency (good).\n // It could help when we have\n // small messages like in our grpc transactions.\n // And it also could help when we have tcp forwarding to not buffer messages in the middle.\n (client as any).setNoDelay(true);\n });\n}\n\nasync function forwardOut(logger: MiLogger, conn: Client, localHost: string, localPort: number, remoteHost: string, remotePort: number): Promise<ClientChannel> {\n return new Promise((resolve, reject) => {\n conn.forwardOut(localHost, localPort, remoteHost, remotePort, (err, stream) => {\n if (err) {\n logger.error(`forwardOut.error: ${err}`);\n return reject(err);\n }\n\n return resolve(stream);\n });\n });\n}\n"],"names":[],"mappings":";;;;;;;;;AAYA,MAAM,aAAa,GAAkB;AACnC,IAAA,iBAAiB,EAAE,KAAK;AACxB,IAAA,iBAAiB,EAAE,EAAE;CACtB;MASY,SAAS,CAAA;AAMD,IAAA,MAAA;AACA,IAAA,MAAA;AANX,IAAA,MAAM;AACP,IAAA,OAAO;IACN,gBAAgB,GAAiB,EAAE;IAE3C,WAAA,CACmB,MAAgB,EAChB,MAAc,EAAA;QADd,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,MAAM,GAAN,MAAM;IACtB;AAEH;;;;AAIG;AACI,IAAA,aAAa,IAAI,CAAC,MAAgB,EAAE,MAAqB,EAAA;AAC9D,QAAA,MAAM,YAAY,GAAG;AACnB,YAAA,GAAG,aAAa;AAChB,YAAA,GAAG,MAAM;SACV;QAED,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,MAAM,EAAE,IAAI,MAAM,EAAE,CAAC;AAClD,QAAA,MAAM,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC;AAElC,QAAA,OAAO,MAAM;IACf;IAEO,mBAAmB,GAAA;QACxB,OAAO,IAAI,CAAC,gBAAgB;IAC9B;IAEO,eAAe,GAAA;AACpB,QAAA,OAAO,CAAA,EAAG,IAAI,CAAC,MAAM,EAAE,IAAI,CAAA,CAAA,EAAI,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE;IACpD;IAEO,WAAW,GAAA;AAChB,QAAA,OAAO,IAAI,CAAC,MAAM,EAAE,QAAQ;IAC9B;AAEA;;;;AAIG;IACI,MAAM,OAAO,CAAC,MAAqB,EAA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ACJ;AAEA,eAAe,UAAU,CAAC,MAAgB,EAAE,IAAY,EAAE,SAAiB,EAAE,SAAiB,EAAE,UAAkB,EAAE,UAAkB,EAAA;IACpI,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAI;AACrC,QAAA,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAI;YAC5E,IAAI,GAAG,EAAE;AACP,gBAAA,MAAM,CAAC,KAAK,CAAC,qBAAqB,GAAG,CAAA,CAAE,CAAC;AACxC,gBAAA,OAAO,MAAM,CAAC,GAAG,CAAC;YACpB;AAEA,YAAA,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,QAAA,CAAC,CAAC;AACJ,IAAA,CAAC,CAAC;AACJ;;;;"}
@@ -0,0 +1,149 @@
1
+ 'use strict';
2
+
3
+ var pl_paths = require('./pl_paths.cjs');
4
+ var node_crypto = require('node:crypto');
5
+
6
+ /** Provides helper functions to work with supervisord */
7
+ async function supervisorCtlStart(sshClient, remoteHome, arch) {
8
+ const result = await supervisorExec(sshClient, remoteHome, arch, '--daemon');
9
+ if (result.stderr) {
10
+ throw new Error(`Can not run ssh Platforma ${result.stderr}`);
11
+ }
12
+ }
13
+ async function supervisorStop(sshClient, remoteHome, arch) {
14
+ const result = await supervisorExec(sshClient, remoteHome, arch, 'ctl shutdown');
15
+ if (result.stderr) {
16
+ throw new Error(`Can not stop ssh Platforma ${result.stderr}`);
17
+ }
18
+ }
19
+ function isAllAlive(status, shouldUseMinio) {
20
+ if (shouldUseMinio) {
21
+ return status.platforma && status.minio;
22
+ }
23
+ return status.platforma;
24
+ }
25
+ function isSupervisordRunning(status) {
26
+ return status.execError === undefined;
27
+ }
28
+ async function supervisorStatus(logger, sshClient, remoteHome, arch) {
29
+ let result;
30
+ try {
31
+ result = await supervisorExec(sshClient, remoteHome, arch, 'ctl status');
32
+ }
33
+ catch (e) {
34
+ return { execError: String(e) };
35
+ }
36
+ if (result.stderr) {
37
+ logger.info(`supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`);
38
+ return { rawResult: result };
39
+ }
40
+ const platforma = isProgramRunning(result.stdout, 'platforma');
41
+ const minio = isProgramRunning(result.stdout, 'minio');
42
+ const status = {
43
+ rawResult: result,
44
+ platforma,
45
+ minio,
46
+ };
47
+ if (!status.minio) {
48
+ logger.warn('Minio is not running on the server');
49
+ }
50
+ if (!status.platforma) {
51
+ logger.warn('Platforma is not running on the server');
52
+ }
53
+ return status;
54
+ }
55
+ /** Generates the config for supervisord.
56
+ * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings
57
+ */
58
+ function generateSupervisordConfig(supervisorRemotePort, remoteWorkDir, platformaConfigPath, plPath) {
59
+ const password = node_crypto.randomBytes(16).toString('hex');
60
+ const freePort = supervisorRemotePort;
61
+ return `
62
+ [supervisord]
63
+ logfile=${remoteWorkDir}/supervisord.log
64
+ loglevel=info
65
+ pidfile=${remoteWorkDir}/supervisord.pid
66
+
67
+ [inet_http_server]
68
+ port=127.0.0.1:${freePort}
69
+ username=default-user
70
+ password=${password}
71
+
72
+ [supervisorctl]
73
+ serverurl=http://127.0.0.1:${freePort}
74
+ username=default-user
75
+ password=${password}
76
+
77
+ [program:platforma]
78
+ autostart=true
79
+ command=${plPath} --config ${platformaConfigPath}
80
+ directory=${remoteWorkDir}
81
+ autorestart=true
82
+ stdout_logfile=${remoteWorkDir}/platforma_cli_logs.log
83
+ stdout_logfile_maxbytes=10000
84
+ stdout_logfile_backups=10
85
+ redirect_stderr=true
86
+ `;
87
+ }
88
+ /** @deprecated, we use minio only on old deployments that existed before we remove minio,
89
+ * for new servers use generation of the config above. */
90
+ function generateSupervisordConfigWithMinio(minioStorageDir, minioEnvs, supervisorRemotePort, remoteWorkDir, platformaConfigPath, minioPath, plPath) {
91
+ const minioEnvStr = Object.entries(minioEnvs).map(([key, value]) => `${key}="${value}"`).join(',');
92
+ const password = node_crypto.randomBytes(16).toString('hex');
93
+ const freePort = supervisorRemotePort;
94
+ return `
95
+ [supervisord]
96
+ logfile=${remoteWorkDir}/supervisord.log
97
+ loglevel=info
98
+ pidfile=${remoteWorkDir}/supervisord.pid
99
+
100
+ [inet_http_server]
101
+ port=127.0.0.1:${freePort}
102
+ username=default-user
103
+ password=${password}
104
+
105
+ [supervisorctl]
106
+ serverurl=http://127.0.0.1:${freePort}
107
+ username=default-user
108
+ password=${password}
109
+
110
+ [program:platforma]
111
+ autostart=true
112
+ depends_on=minio
113
+ command=${plPath} --config ${platformaConfigPath}
114
+ directory=${remoteWorkDir}
115
+ autorestart=true
116
+
117
+ [program:minio]
118
+ autostart=true
119
+ environment=${minioEnvStr}
120
+ command=${minioPath} server ${minioStorageDir}
121
+ directory=${remoteWorkDir}
122
+ autorestart=true
123
+ `;
124
+ }
125
+ async function supervisorExec(sshClient, remoteHome, arch, command) {
126
+ const supervisorCmd = pl_paths.supervisorBin(remoteHome, arch);
127
+ const supervisorConf = pl_paths.supervisorConf(remoteHome);
128
+ const cmd = `${supervisorCmd} --configuration ${supervisorConf} ${command}`;
129
+ return await sshClient.exec(cmd);
130
+ }
131
+ function isProgramRunning(output, programName) {
132
+ // eslint-disable-next-line no-control-regex
133
+ const stripAnsi = (str) => str.replace(/\x1B\[[0-9;]*m/g, '');
134
+ const cleanedOutput = stripAnsi(output);
135
+ return cleanedOutput.split('\n').some((line) => {
136
+ const [name, status] = line.trim().split(/\s{2,}/); // Split string by 2 spaces.
137
+ return name === programName && status === 'Running';
138
+ });
139
+ }
140
+
141
+ exports.generateSupervisordConfig = generateSupervisordConfig;
142
+ exports.generateSupervisordConfigWithMinio = generateSupervisordConfigWithMinio;
143
+ exports.isAllAlive = isAllAlive;
144
+ exports.isSupervisordRunning = isSupervisordRunning;
145
+ exports.supervisorCtlStart = supervisorCtlStart;
146
+ exports.supervisorExec = supervisorExec;
147
+ exports.supervisorStatus = supervisorStatus;
148
+ exports.supervisorStop = supervisorStop;
149
+ //# sourceMappingURL=supervisord.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisord.cjs","sources":["../../src/ssh/supervisord.ts"],"sourcesContent":["/** Provides helper functions to work with supervisord */\n\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport * as plpath from './pl_paths';\nimport type { SshClient, SshExecResult } from './ssh';\nimport { randomBytes } from 'node:crypto';\n\nexport async function supervisorCtlStart(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n) {\n const result = await supervisorExec(sshClient, remoteHome, arch, '--daemon');\n\n if (result.stderr) {\n throw new Error(`Can not run ssh Platforma ${result.stderr}`);\n }\n}\n\nexport async function supervisorStop(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n) {\n const result = await supervisorExec(sshClient, remoteHome, arch, 'ctl shutdown');\n\n if (result.stderr) {\n throw new Error(`Can not stop ssh Platforma ${result.stderr}`);\n }\n}\n\n/** Provides a simple true/false response got from supervisord status\n * along with a debug info that could be showed in error logs (raw response from the command, parsed response etc). */\nexport type SupervisorStatus = {\n platforma?: boolean;\n minio?: boolean;\n rawResult?: SshExecResult;\n execError?: string;\n};\n\nexport function isAllAlive(status: SupervisorStatus, shouldUseMinio: boolean) {\n if (shouldUseMinio) {\n return status.platforma && status.minio;\n }\n\n return status.platforma;\n}\n\nexport function isSupervisordRunning(status: SupervisorStatus) {\n return status.execError === undefined;\n}\n\nexport async function supervisorStatus(\n logger: MiLogger,\n sshClient: SshClient,\n remoteHome: string, arch: string,\n): Promise<SupervisorStatus> {\n let result: SshExecResult;\n try {\n result = await supervisorExec(sshClient, remoteHome, arch, 'ctl status');\n } catch (e: unknown) {\n return { execError: String(e) };\n }\n\n if (result.stderr) {\n logger.info(`supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`);\n\n return { rawResult: result };\n }\n\n const platforma = isProgramRunning(result.stdout, 'platforma');\n const minio = isProgramRunning(result.stdout, 'minio');\n const status: SupervisorStatus = {\n rawResult: result,\n platforma,\n minio,\n };\n\n if (!status.minio) {\n logger.warn('Minio is not running on the server');\n }\n\n if (!status.platforma) {\n logger.warn('Platforma is not running on the server');\n }\n\n return status;\n}\n\n/** Generates the config for supervisord.\n * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings\n */\nexport function generateSupervisordConfig(\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n plPath: string,\n) {\n const password = randomBytes(16).toString('hex');\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\nstdout_logfile=${remoteWorkDir}/platforma_cli_logs.log\nstdout_logfile_maxbytes=10000\nstdout_logfile_backups=10\nredirect_stderr=true\n`;\n}\n\n/** @deprecated, we use minio only on old deployments that existed before we remove minio,\n * for new servers use generation of the config above. */\nexport function generateSupervisordConfigWithMinio(\n minioStorageDir: string,\n minioEnvs: Record<string, string>,\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n\n minioPath: string,\n plPath: string,\n) {\n const minioEnvStr = Object.entries(minioEnvs).map(([key, value]) => `${key}=\"${value}\"`).join(',');\n const password = randomBytes(16).toString('hex');\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ndepends_on=minio\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\n\n[program:minio]\nautostart=true\nenvironment=${minioEnvStr}\ncommand=${minioPath} server ${minioStorageDir}\ndirectory=${remoteWorkDir}\nautorestart=true\n`;\n}\n\nexport async function supervisorExec(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n command: string,\n) {\n const supervisorCmd = plpath.supervisorBin(remoteHome, arch);\n const supervisorConf = plpath.supervisorConf(remoteHome);\n\n const cmd = `${supervisorCmd} --configuration ${supervisorConf} ${command}`;\n return await sshClient.exec(cmd);\n}\n\nfunction isProgramRunning(output: string, programName: string) {\n // eslint-disable-next-line no-control-regex\n const stripAnsi = (str: string) => str.replace(/\\x1B\\[[0-9;]*m/g, '');\n\n const cleanedOutput = stripAnsi(output);\n\n return cleanedOutput.split('\\n').some((line) => {\n const [name, status] = line.trim().split(/\\s{2,}/); // Split string by 2 spaces.\n\n return name === programName && status === 'Running';\n });\n}\n"],"names":["randomBytes","plpath.supervisorBin","plpath.supervisorConf"],"mappings":";;;;;AAAA;AAOO,eAAe,kBAAkB,CACtC,SAAoB,EACpB,UAAkB,EAAE,IAAY,EAAA;AAEhC,IAAA,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC;AAE5E,IAAA,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,CAAA,0BAAA,EAA6B,MAAM,CAAC,MAAM,CAAA,CAAE,CAAC;IAC/D;AACF;AAEO,eAAe,cAAc,CAClC,SAAoB,EACpB,UAAkB,EAAE,IAAY,EAAA;AAEhC,IAAA,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,cAAc,CAAC;AAEhF,IAAA,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,CAAA,2BAAA,EAA8B,MAAM,CAAC,MA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,cAAc,CAClC,SAAoB,EACpB,UAAkB,EAAE,IAAY,EAChC,OAAe,EAAA;IAEf,MAAM,aAAa,GAAGC,sBAAoB,CAAC,UAAU,EAAE,IAAI,CAAC;IAC5D,MAAM,cAAc,GAAGC,uBAAqB,CAAC,UAAU,CAAC;IAExD,MAAM,GAAG,GAAG,CAAA,EAAG,aAAa,oBAAoB,cAAc,CAAA,CAAA,EAAI,OAAO,CAAA,CAAE;AAC3E,IAAA,OAAO,MAAM,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC;AAClC;AAEA,SAAS,gBAAgB,CAAC,MAAc,EAAE,WAAmB,EAAA;;AAE3D,IAAA,MAAM,SAAS,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC;AAErE,IAAA,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,CAAC;AAEvC,IAAA,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAI;AAC7C,QAAA,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAEnD,QAAA,OAAO,IAAI,KAAK,WAAW,IAAI,MAAM,KAAK,SAAS;AACrD,IAAA,CAAC,CAAC;AACJ;;;;;;;;;;;"}
@@ -21,4 +21,3 @@ export declare function generateSupervisordConfig(supervisorRemotePort: number,
21
21
  * for new servers use generation of the config above. */
22
22
  export declare function generateSupervisordConfigWithMinio(minioStorageDir: string, minioEnvs: Record<string, string>, supervisorRemotePort: number, remoteWorkDir: string, platformaConfigPath: string, minioPath: string, plPath: string): string;
23
23
  export declare function supervisorExec(sshClient: SshClient, remoteHome: string, arch: string, command: string): Promise<SshExecResult>;
24
- //# sourceMappingURL=supervisord.d.ts.map
@@ -0,0 +1,140 @@
1
+ import { supervisorBin, supervisorConf } from './pl_paths.js';
2
+ import { randomBytes } from 'node:crypto';
3
+
4
+ /** Provides helper functions to work with supervisord */
5
+ async function supervisorCtlStart(sshClient, remoteHome, arch) {
6
+ const result = await supervisorExec(sshClient, remoteHome, arch, '--daemon');
7
+ if (result.stderr) {
8
+ throw new Error(`Can not run ssh Platforma ${result.stderr}`);
9
+ }
10
+ }
11
+ async function supervisorStop(sshClient, remoteHome, arch) {
12
+ const result = await supervisorExec(sshClient, remoteHome, arch, 'ctl shutdown');
13
+ if (result.stderr) {
14
+ throw new Error(`Can not stop ssh Platforma ${result.stderr}`);
15
+ }
16
+ }
17
+ function isAllAlive(status, shouldUseMinio) {
18
+ if (shouldUseMinio) {
19
+ return status.platforma && status.minio;
20
+ }
21
+ return status.platforma;
22
+ }
23
+ function isSupervisordRunning(status) {
24
+ return status.execError === undefined;
25
+ }
26
+ async function supervisorStatus(logger, sshClient, remoteHome, arch) {
27
+ let result;
28
+ try {
29
+ result = await supervisorExec(sshClient, remoteHome, arch, 'ctl status');
30
+ }
31
+ catch (e) {
32
+ return { execError: String(e) };
33
+ }
34
+ if (result.stderr) {
35
+ logger.info(`supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`);
36
+ return { rawResult: result };
37
+ }
38
+ const platforma = isProgramRunning(result.stdout, 'platforma');
39
+ const minio = isProgramRunning(result.stdout, 'minio');
40
+ const status = {
41
+ rawResult: result,
42
+ platforma,
43
+ minio,
44
+ };
45
+ if (!status.minio) {
46
+ logger.warn('Minio is not running on the server');
47
+ }
48
+ if (!status.platforma) {
49
+ logger.warn('Platforma is not running on the server');
50
+ }
51
+ return status;
52
+ }
53
+ /** Generates the config for supervisord.
54
+ * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings
55
+ */
56
+ function generateSupervisordConfig(supervisorRemotePort, remoteWorkDir, platformaConfigPath, plPath) {
57
+ const password = randomBytes(16).toString('hex');
58
+ const freePort = supervisorRemotePort;
59
+ return `
60
+ [supervisord]
61
+ logfile=${remoteWorkDir}/supervisord.log
62
+ loglevel=info
63
+ pidfile=${remoteWorkDir}/supervisord.pid
64
+
65
+ [inet_http_server]
66
+ port=127.0.0.1:${freePort}
67
+ username=default-user
68
+ password=${password}
69
+
70
+ [supervisorctl]
71
+ serverurl=http://127.0.0.1:${freePort}
72
+ username=default-user
73
+ password=${password}
74
+
75
+ [program:platforma]
76
+ autostart=true
77
+ command=${plPath} --config ${platformaConfigPath}
78
+ directory=${remoteWorkDir}
79
+ autorestart=true
80
+ stdout_logfile=${remoteWorkDir}/platforma_cli_logs.log
81
+ stdout_logfile_maxbytes=10000
82
+ stdout_logfile_backups=10
83
+ redirect_stderr=true
84
+ `;
85
+ }
86
+ /** @deprecated, we use minio only on old deployments that existed before we remove minio,
87
+ * for new servers use generation of the config above. */
88
+ function generateSupervisordConfigWithMinio(minioStorageDir, minioEnvs, supervisorRemotePort, remoteWorkDir, platformaConfigPath, minioPath, plPath) {
89
+ const minioEnvStr = Object.entries(minioEnvs).map(([key, value]) => `${key}="${value}"`).join(',');
90
+ const password = randomBytes(16).toString('hex');
91
+ const freePort = supervisorRemotePort;
92
+ return `
93
+ [supervisord]
94
+ logfile=${remoteWorkDir}/supervisord.log
95
+ loglevel=info
96
+ pidfile=${remoteWorkDir}/supervisord.pid
97
+
98
+ [inet_http_server]
99
+ port=127.0.0.1:${freePort}
100
+ username=default-user
101
+ password=${password}
102
+
103
+ [supervisorctl]
104
+ serverurl=http://127.0.0.1:${freePort}
105
+ username=default-user
106
+ password=${password}
107
+
108
+ [program:platforma]
109
+ autostart=true
110
+ depends_on=minio
111
+ command=${plPath} --config ${platformaConfigPath}
112
+ directory=${remoteWorkDir}
113
+ autorestart=true
114
+
115
+ [program:minio]
116
+ autostart=true
117
+ environment=${minioEnvStr}
118
+ command=${minioPath} server ${minioStorageDir}
119
+ directory=${remoteWorkDir}
120
+ autorestart=true
121
+ `;
122
+ }
123
+ async function supervisorExec(sshClient, remoteHome, arch, command) {
124
+ const supervisorCmd = supervisorBin(remoteHome, arch);
125
+ const supervisorConf$1 = supervisorConf(remoteHome);
126
+ const cmd = `${supervisorCmd} --configuration ${supervisorConf$1} ${command}`;
127
+ return await sshClient.exec(cmd);
128
+ }
129
+ function isProgramRunning(output, programName) {
130
+ // eslint-disable-next-line no-control-regex
131
+ const stripAnsi = (str) => str.replace(/\x1B\[[0-9;]*m/g, '');
132
+ const cleanedOutput = stripAnsi(output);
133
+ return cleanedOutput.split('\n').some((line) => {
134
+ const [name, status] = line.trim().split(/\s{2,}/); // Split string by 2 spaces.
135
+ return name === programName && status === 'Running';
136
+ });
137
+ }
138
+
139
+ export { generateSupervisordConfig, generateSupervisordConfigWithMinio, isAllAlive, isSupervisordRunning, supervisorCtlStart, supervisorExec, supervisorStatus, supervisorStop };
140
+ //# sourceMappingURL=supervisord.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisord.js","sources":["../../src/ssh/supervisord.ts"],"sourcesContent":["/** Provides helper functions to work with supervisord */\n\nimport type { MiLogger } from '@milaboratories/ts-helpers';\nimport * as plpath from './pl_paths';\nimport type { SshClient, SshExecResult } from './ssh';\nimport { randomBytes } from 'node:crypto';\n\nexport async function supervisorCtlStart(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n) {\n const result = await supervisorExec(sshClient, remoteHome, arch, '--daemon');\n\n if (result.stderr) {\n throw new Error(`Can not run ssh Platforma ${result.stderr}`);\n }\n}\n\nexport async function supervisorStop(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n) {\n const result = await supervisorExec(sshClient, remoteHome, arch, 'ctl shutdown');\n\n if (result.stderr) {\n throw new Error(`Can not stop ssh Platforma ${result.stderr}`);\n }\n}\n\n/** Provides a simple true/false response got from supervisord status\n * along with a debug info that could be showed in error logs (raw response from the command, parsed response etc). */\nexport type SupervisorStatus = {\n platforma?: boolean;\n minio?: boolean;\n rawResult?: SshExecResult;\n execError?: string;\n};\n\nexport function isAllAlive(status: SupervisorStatus, shouldUseMinio: boolean) {\n if (shouldUseMinio) {\n return status.platforma && status.minio;\n }\n\n return status.platforma;\n}\n\nexport function isSupervisordRunning(status: SupervisorStatus) {\n return status.execError === undefined;\n}\n\nexport async function supervisorStatus(\n logger: MiLogger,\n sshClient: SshClient,\n remoteHome: string, arch: string,\n): Promise<SupervisorStatus> {\n let result: SshExecResult;\n try {\n result = await supervisorExec(sshClient, remoteHome, arch, 'ctl status');\n } catch (e: unknown) {\n return { execError: String(e) };\n }\n\n if (result.stderr) {\n logger.info(`supervisord ctl status: stderr occurred: ${result.stderr}, stdout: ${result.stdout}`);\n\n return { rawResult: result };\n }\n\n const platforma = isProgramRunning(result.stdout, 'platforma');\n const minio = isProgramRunning(result.stdout, 'minio');\n const status: SupervisorStatus = {\n rawResult: result,\n platforma,\n minio,\n };\n\n if (!status.minio) {\n logger.warn('Minio is not running on the server');\n }\n\n if (!status.platforma) {\n logger.warn('Platforma is not running on the server');\n }\n\n return status;\n}\n\n/** Generates the config for supervisord.\n * docs: https://github.com/ochinchina/supervisord?tab=readme-ov-file#supervised-program-settings\n */\nexport function generateSupervisordConfig(\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n plPath: string,\n) {\n const password = randomBytes(16).toString('hex');\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\nstdout_logfile=${remoteWorkDir}/platforma_cli_logs.log\nstdout_logfile_maxbytes=10000\nstdout_logfile_backups=10\nredirect_stderr=true\n`;\n}\n\n/** @deprecated, we use minio only on old deployments that existed before we remove minio,\n * for new servers use generation of the config above. */\nexport function generateSupervisordConfigWithMinio(\n minioStorageDir: string,\n minioEnvs: Record<string, string>,\n supervisorRemotePort: number,\n remoteWorkDir: string,\n platformaConfigPath: string,\n\n minioPath: string,\n plPath: string,\n) {\n const minioEnvStr = Object.entries(minioEnvs).map(([key, value]) => `${key}=\"${value}\"`).join(',');\n const password = randomBytes(16).toString('hex');\n const freePort = supervisorRemotePort;\n\n return `\n[supervisord]\nlogfile=${remoteWorkDir}/supervisord.log\nloglevel=info\npidfile=${remoteWorkDir}/supervisord.pid\n\n[inet_http_server]\nport=127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[supervisorctl]\nserverurl=http://127.0.0.1:${freePort}\nusername=default-user\npassword=${password}\n\n[program:platforma]\nautostart=true\ndepends_on=minio\ncommand=${plPath} --config ${platformaConfigPath}\ndirectory=${remoteWorkDir}\nautorestart=true\n\n[program:minio]\nautostart=true\nenvironment=${minioEnvStr}\ncommand=${minioPath} server ${minioStorageDir}\ndirectory=${remoteWorkDir}\nautorestart=true\n`;\n}\n\nexport async function supervisorExec(\n sshClient: SshClient,\n remoteHome: string, arch: string,\n command: string,\n) {\n const supervisorCmd = plpath.supervisorBin(remoteHome, arch);\n const supervisorConf = plpath.supervisorConf(remoteHome);\n\n const cmd = `${supervisorCmd} --configuration ${supervisorConf} ${command}`;\n return await sshClient.exec(cmd);\n}\n\nfunction isProgramRunning(output: string, programName: string) {\n // eslint-disable-next-line no-control-regex\n const stripAnsi = (str: string) => str.replace(/\\x1B\\[[0-9;]*m/g, '');\n\n const cleanedOutput = stripAnsi(output);\n\n return cleanedOutput.split('\\n').some((line) => {\n const [name, status] = line.trim().split(/\\s{2,}/); // Split string by 2 spaces.\n\n return name === programName && status === 'Running';\n });\n}\n"],"names":["plpath.supervisorBin","supervisorConf","plpath.supervisorConf"],"mappings":";;;AAAA;AAOO,eAAe,kBAAkB,CACtC,SAAoB,EACpB,UAAkB,EAAE,IAAY,EAAA;AAEhC,IAAA,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,SAAS,EAAE,UAAU,EAAE,I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AM,KAAK,SAAS;AACrD,IAAA,CAAC,CAAC;AACJ;;;;"}
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@milaboratories/pl-deployments",
3
- "version": "2.4.7",
3
+ "version": "2.4.9",
4
4
  "pl-version": "1.35.2",
5
5
  "description": "MiLaboratories Platforma Backend code service run wrapper",
6
6
  "engines": {
7
7
  "node": ">=20.16.0"
8
8
  },
9
9
  "types": "./dist/index.d.ts",
10
- "main": "./dist/index.js",
11
- "module": "./dist/index.mjs",
10
+ "main": "./dist/index.cjs",
11
+ "module": "./dist/index.js",
12
12
  "exports": {
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts",
15
- "require": "./dist/index.js",
16
- "import": "./dist/index.mjs"
15
+ "require": "./dist/index.cjs",
16
+ "import": "./dist/index.js"
17
17
  }
18
18
  },
19
19
  "files": [
@@ -40,25 +40,27 @@
40
40
  "tsconfig-paths": "^4.2.0",
41
41
  "typescript": "~5.6.3",
42
42
  "utility-types": "^3.11.0",
43
- "vite": "^6.3.5",
44
43
  "vitest": "^2.1.9",
45
- "@milaboratories/build-configs": "1.0.5",
46
- "@milaboratories/eslint-config": "^1.0.4"
44
+ "@milaboratories/ts-configs": "1.0.6",
45
+ "@milaboratories/eslint-config": "^1.0.4",
46
+ "@milaboratories/ts-builder": "1.0.2",
47
+ "@milaboratories/build-configs": "1.0.6"
47
48
  },
48
49
  "dependencies": {
49
50
  "decompress": "^4.2.1",
50
51
  "upath": "^2.0.1",
51
52
  "ssh2": "^1.16.0",
52
53
  "tar": "^7.4.3",
53
- "undici": "~7.10.0",
54
- "yaml": "^2.7.0",
54
+ "undici": "~7.13.0",
55
+ "yaml": "^2.8.0",
55
56
  "zod": "~3.23.8",
56
- "@milaboratories/pl-config": "^1.6.3",
57
- "@milaboratories/ts-helpers": "^1.4.3"
57
+ "@milaboratories/ts-helpers": "^1.4.4",
58
+ "@milaboratories/pl-config": "^1.7.0"
58
59
  },
59
60
  "scripts": {
60
- "type-check": "tsc --noEmit --composite false",
61
- "build": "vite build",
61
+ "type-check": "ts-builder types --target node",
62
+ "build": "ts-builder build --target node",
63
+ "watch": "ts-builder build --target node --watch",
62
64
  "lint": "eslint .",
63
65
  "test": "vitest",
64
66
  "do-pack": "rm -rf src/.test && rm -f *.tgz && pnpm pack && mv *.tgz package.tgz",
@@ -1,5 +1,6 @@
1
- declare const PL_VERSION: string;
1
+ import packageJson from '../../package.json';
2
2
 
3
3
  export function getDefaultPlVersion(): string {
4
- return PL_VERSION;
4
+ // drop build error if pl-version is not defined
5
+ return packageJson['pl-version'];
5
6
  }
package/src/local/pl.ts CHANGED
@@ -203,7 +203,12 @@ async function localPlatformaReadPidAndStop(
203
203
 
204
204
  if (oldPid !== undefined && alive) {
205
205
  trace('stopped', processStop(oldPid));
206
- trace('waitStopped', await processWaitStopped(oldPid, 10_000));
206
+ try {
207
+ trace('waitStopped', await processWaitStopped(oldPid, 15_000)); // larger, that 10s we provide to backend in config.
208
+ } catch (_e) {
209
+ trace('forceStopped', processStop(oldPid, true));
210
+ trace('waitForceStopped', await processWaitStopped(oldPid, 5_000));
211
+ }
207
212
  }
208
213
 
209
214
  return t;
@@ -1,5 +1,6 @@
1
1
  import type { SpawnOptions, ChildProcess } from 'node:child_process';
2
2
  import { spawn } from 'node:child_process';
3
+ import { execSync } from 'node:child_process';
3
4
  import type { MiLogger } from '@milaboratories/ts-helpers';
4
5
  import { sleep } from '@milaboratories/ts-helpers';
5
6
 
@@ -22,14 +23,50 @@ wd: ${opts.opts.cwd}`);
22
23
  export async function isProcessAlive(pid: number) {
23
24
  try {
24
25
  process.kill(pid, 0);
25
- return true;
26
+
27
+ // Check we look at 'platforma' to not kill wrong process.
28
+ const processName = getProcessName(pid);
29
+ if (process.platform === 'win32') {
30
+ return processName === 'platforma.exe'; // process name does not contain path to the file.
31
+ }
32
+
33
+ // Linux and Mac OS X behave differently (so can different Linux distributions).
34
+ // Process name can contain original path to the binary file or just its name.
35
+ return processName.endsWith('/platforma') || processName === 'platforma';
26
36
  } catch (_e) {
27
37
  return false;
28
38
  }
29
39
  }
30
40
 
31
- export function processStop(pid: number) {
32
- return process.kill(pid, 'SIGINT');
41
+ function getProcessName(pid: number): string {
42
+ try {
43
+ if (process.platform === 'win32') {
44
+ // Windows: use tasklist command
45
+ const output = execSync(`tasklist /FI "PID eq ${pid}" /FO CSV /NH`, { encoding: 'utf8' });
46
+ const lines = output.trim().split('\n');
47
+ if (lines.length > 0 && lines[0].includes(',')) {
48
+ const parts = lines[0].split(',');
49
+ if (parts.length >= 1) {
50
+ // Remove quotes and get the executable name
51
+ const exeName = parts[0].replace(/^"|"$/g, '').trim();
52
+ return exeName;
53
+ }
54
+ }
55
+ } else {
56
+ // Unix-like systems: use ps command
57
+ const output = execSync(`ps -p ${pid} -o comm=`, { encoding: 'utf8' });
58
+ const processName = output.trim();
59
+ return processName;
60
+ }
61
+ } catch (_error) {
62
+ // If we can't get the process name, return empty string
63
+ return '';
64
+ }
65
+ return '';
66
+ }
67
+
68
+ export function processStop(pid: number, force: boolean = false) {
69
+ return process.kill(pid, force ? 'SIGKILL' : 'SIGINT');
33
70
  }
34
71
 
35
72
  export async function processWaitStopped(pid: number, maxMs: number) {
@@ -1 +0,0 @@
1
- {"version":3,"file":"os_and_arch.d.ts","sourceRoot":"","sources":["../../src/common/os_and_arch.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,wCAAyC,CAAC;AAC3D,MAAM,MAAM,MAAM,GAAG,CAAC,OAAO,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3C,oGAAoG;AACpG,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAc5C;AAED,eAAO,MAAM,MAAM,6BAA8B,CAAC;AAClD,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/C,8FAA8F;AAC9F,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAiB9C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pl_binary.d.ts","sourceRoot":"","sources":["../../src/common/pl_binary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAM3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG5C,0CAA0C;AAC1C,MAAM,MAAM,cAAc,GAAG,sBAAsB,GAAG,mBAAmB,CAAC;AAE1E,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,wBAAgB,wBAAwB,IAAI,sBAAsB,CAEjE;AAED,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,QAAQ,EAChB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,MAAM,CAAC,CAajB;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAIjD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"pl_binary_download.d.ts","sourceRoot":"","sources":["../../src/common/pl_binary_download.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAW3D,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,uBAAuB,EAAE,MAAM,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CA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":"AAEA,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC"}