@drumee/setup-infra 1.0.14 → 1.0.15

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/index.js CHANGED
@@ -12,6 +12,7 @@ const {
12
12
  } = require("fs");
13
13
  const { args, hasExistingSettings } = require('./templates/utils')
14
14
 
15
+
15
16
  const JSON_OPT = { spaces: 2, EOL: "\r\n" };
16
17
 
17
18
  const {
@@ -100,7 +101,8 @@ function worker(data, instances = 1, exec_mode = 'fork_mode') {
100
101
 
101
102
  if (!server_dir) server_dir = join(runtime_dir, 'server');
102
103
  let base = `${server_dir}/${route}`;
103
- return {
104
+ let iname = name.replace('/', '-');
105
+ let opt = {
104
106
  name,
105
107
  script,
106
108
  cwd: base,
@@ -113,8 +115,40 @@ function worker(data, instances = 1, exec_mode = 'fork_mode') {
113
115
  },
114
116
  dependencies: [`pm2-logrotate`],
115
117
  exec_mode,
116
- instances
118
+ instances,
119
+ out_file: join(data.log_dir, `log-${iname}.log`),
120
+ error_file: join(data.log_dir, `error-${iname}.log`),
121
+ pm2_log_routes: {
122
+ rotateInterval: '0 0 * * *', // Rotate daily at midnight
123
+ rotateModule: true,
124
+ max_size: '10M', // Rotate when log reaches 10MB
125
+ retain: 30 // Keep 30 rotated logs
126
+ }
117
127
  };
128
+ if (args.watch_dirs) {
129
+ let dirs = args.watch_dirs.split(/,+/);
130
+ if (dirs.length) {
131
+ opt.watch = dirs;
132
+ opt.watch_delay = args.watch_delay;
133
+ if (args.watch_symlinks) {
134
+ opt.watch_options = {
135
+ followSymlinks: true
136
+ }
137
+ } else {
138
+ opt.watch_options = {
139
+ followSymlinks: false
140
+ }
141
+ }
142
+ if (args.watch_ignore) {
143
+ let ignored = args.watch_ignore.split(/,+/);
144
+ if (ignored.length) {
145
+ opt.ignore_watch = ignored;
146
+ }
147
+ }
148
+ }
149
+ }
150
+ return opt;
151
+
118
152
  }
119
153
 
120
154
  /***
@@ -296,10 +330,14 @@ function getSysConfigs() {
296
330
  ["drumee_root", args.drumee_root, "/var/lib/drumee"],
297
331
  ["use_email", use_email, 0],
298
332
  ["db_dir", args.db_dir, '/var/lib/mysql'],
333
+ ["log_dir", args.log_dir, '/var/log/drumee'],
334
+ ["system_user", args.system_user, 'www-data'],
335
+ ["system_group", args.system_group, 'www-data'],
299
336
  ["backup_storage", args.backup_storage, ""],
300
337
  ["data_dir", args.data_dir, '/var/lib/drumee/data'],
301
338
  ["http_port", args.http_port, 80],
302
339
  ["https_port", args.https_port, 443],
340
+ ["verbosity", args.verbosity, 2],
303
341
  ]
304
342
 
305
343
  if (!args.localhost) {
@@ -448,9 +486,13 @@ function writeInfraConf(data) {
448
486
  `${drumee}/conf.d/drumee.json`,
449
487
  `${drumee}/conf.d/myDrumee.json`,
450
488
 
489
+ `${nginx}/nginx.conf`,
490
+
451
491
  `${infra}/mfs.conf`,
452
492
  `${infra}/routes/main.conf`,
453
493
  `${infra}/internals/accel.conf`,
494
+ `${mariadb}/50-server.cnf`,
495
+ `${mariadb}/50-client.cnf`,
454
496
  ];
455
497
 
456
498
  if (args.localhost) {
@@ -465,18 +507,10 @@ function writeInfraConf(data) {
465
507
  targets.push(`${nginx}/sites-enabled/localhost.conf`)
466
508
  let dir = join(args.drumee_root, 'cache', 'localhost')
467
509
  mkdirSync(dir, { recursive: true });
468
- if (args.db_dir != '/var/lib/mysql') {
469
- targets.push(
470
- `${mariadb}/50-server.cnf`,
471
- `${mariadb}/50-client.cnf`,
472
- )
473
- }
474
510
  } else {
475
511
  targets.push(
476
512
  `${bind}/named.conf.log`,
477
513
  `${bind}/named.conf.options`,
478
- `${mariadb}/50-server.cnf`,
479
- `${mariadb}/50-client.cnf`,
480
514
  )
481
515
  }
482
516
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drumee/setup-infra",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "Drumee Infrastructure Setup Utilities",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  "ru",
9
9
  "zh"
10
10
  ],
11
- "verbosity": 2,
11
+ "verbosity": <%= verbosity %>,
12
12
  "useEmail":<%= use_email %>,
13
13
  "quota": {
14
14
  "watermark": "<%= quota_watermark %>"
@@ -33,7 +33,7 @@ export DRUMEE_IMPORT_DIR=<%= import_dir %>
33
33
  export DRUMEE_LOG_DIR=<%= log_dir %>
34
34
  export DRUMEE_ROOT=<%= drumee_root %>
35
35
  export DRUMEE_RUNTIME_DIR=$DRUMEE_ROOT/runtime
36
- export DRUMEE_STATIC_DIR=$DRUMEE_ROOT/static
36
+ export DRUMEE_STATIC_DIR=$DRUMEE_RUNTIME_DIR/static
37
37
  export DRUMEE_UI_HOME=$DRUMEE_RUNTIME_DIR/ui
38
38
  export DRUMEE_SERVER_HOME=$DRUMEE_RUNTIME_DIR/server
39
39
  export DRUMEE_SCHEMAS_DIR=$DRUMEE_SERVER_HOME/schemas
@@ -1,5 +1,5 @@
1
1
 
2
- user www-data;
2
+ user <%= system_user %>;
3
3
  worker_processes 4;
4
4
  pid /run/nginx.pid;
5
5
  include /etc/nginx/modules-enabled/*.conf;
@@ -60,6 +60,18 @@ parser.add_argument("--outdir", {
60
60
  help: "If set, takes precedent on chroot. Output root. Defaulted to /",
61
61
  });
62
62
 
63
+ parser.add_argument("--log-dir", {
64
+ type: String,
65
+ default: '/var/log/drumee',
66
+ help: "Drumee server log location",
67
+ });
68
+
69
+ parser.add_argument("--verbosity", {
70
+ type: "int",
71
+ default: 2,
72
+ help: "Server log level",
73
+ });
74
+
63
75
  parser.add_argument("--public-domain", {
64
76
  type: String,
65
77
  default: PUBLIC_DOMAIN,
@@ -137,6 +149,42 @@ parser.add_argument("--db-dir", {
137
149
  help: "Partition or directory dedicated to store drumee database",
138
150
  });
139
151
 
152
+ parser.add_argument("--system-user", {
153
+ type: String,
154
+ default: "www-data",
155
+ help: "System user used to run Drumee",
156
+ });
157
+
158
+ parser.add_argument("--system-group", {
159
+ type: String,
160
+ default: "www-data",
161
+ help: "System group used to run Drumee",
162
+ });
163
+
164
+ parser.add_argument("--watch-dirs", {
165
+ type: String,
166
+ default: null,
167
+ help: "pm2 watch directories",
168
+ });
169
+
170
+ parser.add_argument("--watch-delay", {
171
+ type: 'int',
172
+ default: 1000,
173
+ help: "pm2 watch delay",
174
+ });
175
+
176
+ parser.add_argument("--watch-symlinks", {
177
+ type: 'int',
178
+ default: 0,
179
+ help: "pm2 watch delay",
180
+ });
181
+
182
+ parser.add_argument("--watch-ignore", {
183
+ type: String,
184
+ default: null,
185
+ help: "pm2 ignore directories",
186
+ });
187
+
140
188
  parser.add_argument("--drumee-root", {
141
189
  type: String,
142
190
  default: DRUMEE_ROOT || "/var/lib/drumee",
package/thidima.sh DELETED
@@ -1,44 +0,0 @@
1
- # Change below values accordingly to you setup
2
-
3
- # This text will be shown on the login page
4
- export DRUMEE_DESCRIPTION="My Drumee Box"
5
-
6
- # This is the URL base to access your Drumee Instance
7
- # It's recommanded not to share the domain name
8
- # with any oher applications
9
- export DRUMEE_DOMAIN_NAME="thidima.org"
10
-
11
- # Fix IPV4 address bound to your doamain_name
12
- export PUBLIC_IP4="51.195.89.55"
13
-
14
- # IPV6 address bound to your doamain_name
15
- export PUBLIC_IP6="2001:41d0:700:4837::"
16
-
17
- # This email will be use as the admin account
18
- export ADMIN_EMAIL="somanos@drumee.com"
19
-
20
- # Dedicated to data base server. Do not share with any
21
- # other application. Default value is /srv/db.
22
- # At least 100GB should be allocated
23
- export DRUMEE_DB_DIR="/db"
24
-
25
- # Dedicated to Drumee Filesystem Management.
26
- # Do not share with any # other application.
27
- # Default value is /data
28
- # At least 100GB should be allocated
29
- export DRUMEE_DATA_DIR="/data" # defaulted to /data
30
-
31
- # Optional setting
32
- # Drumee use rsync to backup data (FMS, DB and configs)
33
- # If you plan to make a backup on a remote host, ensure
34
- # ssh keys are properly setup
35
- export STORAGE_BACKUP="/backup" # [user@host-or-ip:]/path/
36
-
37
- # If not set, will be defaulted to ADMIN_EMAIL.
38
- # SSL certificates are generated using zerossl.com ACME server
39
- # This requires an emal to be provided.
40
- export ACME_EMAIL_ACCOUNT=""
41
-
42
- mkdir -p $DRUMEE_DB_DIR
43
- mkdir -p $DRUMEE_DATA_DIR
44
- mkdir -p $STORAGE_BACKUP