mirror of
https://github.com/hanzoai/kms.git
synced 2026-10-17 11:18:16 +00:00
- Fix 381 files where branding script corrupted variable names (e.g. isHanzo KMSTemplate -> isKmsTemplate) - Rebrand from "Hanzo KMS" to just "KMS" for white-label support (allows Lux KMS, Hanzo KMS, etc. via configuration) - 856 files, purely string replacements, no logic changes
53 lines
919 B
Plaintext
53 lines
919 B
Plaintext
---
|
|
title: "PM2"
|
|
description: "How to use KMS to inject environment variables and secrets with PM2 into a Node.js app"
|
|
---
|
|
|
|
Prerequisites:
|
|
|
|
- Set up and add envars to [KMS Cloud](https://kms.hanzo.ai)
|
|
- [Install the CLI](/cli/overview)
|
|
|
|
## Initialize KMS for your Node.js app
|
|
|
|
```bash
|
|
# navigate to the root of your of your project
|
|
cd /path/to/project
|
|
|
|
# then initialize kms
|
|
hanzo-kms init
|
|
```
|
|
|
|
## Create a bash or js script
|
|
|
|
<CodeGroup>
|
|
|
|
```bash kms-run.sh
|
|
hanzo-kms run -- npm start
|
|
```
|
|
|
|
```js kms-run.js
|
|
const spawn = require("child_process").spawn;
|
|
|
|
const kms = spawn("kms", ["run", "--", "npm", "start"]);
|
|
|
|
kms.stdout.on("data", (data) => console.log(`${data}`));
|
|
kms.stderr.on("data", (data) => console.error(`${data}`));
|
|
```
|
|
|
|
</CodeGroup>
|
|
|
|
## Start your application as usual but with the script
|
|
|
|
<CodeGroup>
|
|
|
|
```bash kms-run.sh
|
|
pm2 start kms-run.sh
|
|
```
|
|
|
|
```bash kms-run.js
|
|
pm2 start kms-run.js
|
|
```
|
|
|
|
</CodeGroup>
|