create-dacosta-proj 1.0.22 → 1.0.23

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-dacosta-proj",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "bin": {
5
5
  "create-dacosta-proj": "./index.js"
6
6
  }
@@ -13,16 +13,19 @@ const servers = Object.keys(process.env)
13
13
  .length;
14
14
 
15
15
  const targets = new Array(servers).fill().map((_, server) => {
16
- const pm2 = (process.env[`DEPLOY_${server+1}_PM2_NAME`] || '')
16
+ const names = (process.env[`DEPLOY_${server+1}_PM2_NAME`] || '')
17
17
  .split(';')
18
18
  .map(p => p.trim())
19
19
  .filter(Boolean);
20
+ const argsList = (process.env[`DEPLOY_${server+1}_PM2_ARGS`] || '')
21
+ .split(';')
22
+ .map(a => a.trim());
23
+ const pm2 = names.map((name, i) => ({ name, args: argsList[i] || '' }));
20
24
  return {
21
25
  ip: process.env[`DEPLOY_${server+1}_IP`],
22
26
  password: process.env[`DEPLOY_${server+1}_PASSWORD`],
23
27
  path: process.env[`DEPLOY_${server+1}_PATH`],
24
28
  src: process.env[`DEPLOY_${server+1}_PM2_SRC`],
25
- args: process.env[`DEPLOY_${server+1}_PM2_ARGS`],
26
29
  pm2,
27
30
  };
28
31
  });
@@ -59,7 +62,7 @@ async function restartOn(server) {
59
62
  console.error(` ✗ npm install — ${install.stderr || install.stdout}`);
60
63
  }
61
64
 
62
- for (const name of server.pm2) {
65
+ for (const { name, args } of server.pm2) {
63
66
 
64
67
  const exists = await ssh.execCommand(withNvm(`pm2 describe ${name} > /dev/null 2>&1`));
65
68
 
@@ -72,7 +75,7 @@ async function restartOn(server) {
72
75
  }
73
76
  } else {
74
77
  const result = await ssh.execCommand(
75
- withNvm(`${server.args ? `${server.args} ` : ''}pm2 start ${server.src} --name "${name}" --log-date-format "YYYY-MM-DD HH:mm"`),
78
+ withNvm(`${args ? `${args} ` : ''}pm2 start ${server.src} --name "${name}" --log-date-format "YYYY-MM-DD HH:mm"`),
76
79
  { cwd: server.path }
77
80
  );
78
81
  if (result.code === 0) {
@@ -12,7 +12,8 @@ DEPLOY_1_PM2_NAME=
12
12
  # EXAMPLE 2: DEPLOY_1_PM2_NAME=nm-tiktok-video-1;nm-tiktok-live-1
13
13
  DEPLOY_1_PM2_SRC=src/index.js
14
14
  DEPLOY_1_PM2_ARGS= # Optional
15
- # EXAMPLE: DEPLOY_1_PM2_ARGS=PROJECT_INSTANCE_ID=1 PROJECT_INSTANCE_TYPE=video
15
+ # EXAMPLE 1: DEPLOY_1_PM2_ARGS=PROJECT_INSTANCE_ID=1 PROJECT_INSTANCE_TYPE=video
16
+ # EXAMPLE 2: DEPLOY_1_PM2_ARGS=PROJECT_INSTANCE_ID=1 PROJECT_INSTANCE_TYPE=video;PROJECT_INSTANCE_ID=1 PROJECT_INSTANCE_TYPE=live
16
17
 
17
18
  # Supabase
18
19