freeschema 1.0.8 → 1.0.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.
- package/bin/freeschema.js +44 -0
- package/package.json +1 -1
- package/templates/.env.example +5 -0
- package/templates/docker-compose.yml +32 -7
package/bin/freeschema.js
CHANGED
|
@@ -122,6 +122,47 @@ function generateMosquittoPassword(username, password) {
|
|
|
122
122
|
return `${username}:$7$${iterations}$${salt.toString('base64')}$${hash.toString('base64')}\n`;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
function waitForAccessControl(container) {
|
|
126
|
+
process.stdout.write(' Waiting for access-control-server');
|
|
127
|
+
for (let i = 0; i < 30; i++) {
|
|
128
|
+
const r = spawnSync('docker', [
|
|
129
|
+
'exec', container, 'curl', '-sf', 'http://localhost:7000/health'
|
|
130
|
+
], { stdio: 'pipe' });
|
|
131
|
+
if (r.status === 0) { process.stdout.write(' ready\n'); return true; }
|
|
132
|
+
process.stdout.write('.');
|
|
133
|
+
sleep(2000);
|
|
134
|
+
}
|
|
135
|
+
process.stdout.write(' timed out\n');
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function setupSuperAdmin() {
|
|
140
|
+
const env = readEnv();
|
|
141
|
+
const adminId = parseInt(env.SUPER_ADMIN_ID || '100000016', 10);
|
|
142
|
+
const out = runComposeOutput(['ps', '--format', 'json']);
|
|
143
|
+
const containers = out.split('\n')
|
|
144
|
+
.map(l => { try { return JSON.parse(l); } catch { return null; } })
|
|
145
|
+
.filter(Boolean);
|
|
146
|
+
const ac = containers.find(c => c.Service === 'access-control-server');
|
|
147
|
+
if (!ac) return;
|
|
148
|
+
const container = ac.Name || ac.ID;
|
|
149
|
+
|
|
150
|
+
if (!waitForAccessControl(container)) return;
|
|
151
|
+
|
|
152
|
+
const result = spawnSync('docker', [
|
|
153
|
+
'exec', container, 'curl', '-sf',
|
|
154
|
+
'-X', 'POST', 'http://localhost:7000/api/access/super-admin/concept',
|
|
155
|
+
'-H', 'Content-Type: application/json',
|
|
156
|
+
'-d', JSON.stringify({ ConceptId: adminId })
|
|
157
|
+
], { stdio: ['inherit', 'pipe', 'pipe'] });
|
|
158
|
+
|
|
159
|
+
if (result.status === 0) {
|
|
160
|
+
console.log(` Super admin concept ${adminId} ✓`);
|
|
161
|
+
} else {
|
|
162
|
+
console.log(` Super admin already set or skipped`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
125
166
|
function ensureMosquittoConfig(cwd) {
|
|
126
167
|
const dir = (sub) => path.join(cwd, 'mosquitto', sub);
|
|
127
168
|
['config', 'data', 'log'].forEach(d => {
|
|
@@ -556,6 +597,9 @@ async function cmdStart() {
|
|
|
556
597
|
console.log(' Seed applied ✓');
|
|
557
598
|
}
|
|
558
599
|
|
|
600
|
+
console.log('\nFinalizing setup…');
|
|
601
|
+
setupSuperAdmin();
|
|
602
|
+
|
|
559
603
|
console.log('\nFreeSchema is running.');
|
|
560
604
|
console.log(' Status: freeschema status');
|
|
561
605
|
console.log(' Logs: freeschema logs');
|
package/package.json
CHANGED
package/templates/.env.example
CHANGED
|
@@ -188,6 +188,12 @@ services:
|
|
|
188
188
|
condition: service_started
|
|
189
189
|
networks:
|
|
190
190
|
- freeschema-network
|
|
191
|
+
healthcheck:
|
|
192
|
+
test: ["CMD-SHELL", "curl -sI http://localhost:5000/health || exit 1"]
|
|
193
|
+
interval: 1m30s
|
|
194
|
+
timeout: 30s
|
|
195
|
+
retries: 5
|
|
196
|
+
start_period: 30s
|
|
191
197
|
|
|
192
198
|
log-server:
|
|
193
199
|
image: mentorayush/log-server:latest
|
|
@@ -229,6 +235,12 @@ services:
|
|
|
229
235
|
- node-server
|
|
230
236
|
networks:
|
|
231
237
|
- freeschema-network
|
|
238
|
+
healthcheck:
|
|
239
|
+
test: ["CMD-SHELL", "wget -q --spider http://localhost/ || exit 1"]
|
|
240
|
+
interval: 30s
|
|
241
|
+
timeout: 10s
|
|
242
|
+
retries: 3
|
|
243
|
+
start_period: 30s
|
|
232
244
|
|
|
233
245
|
wico-app:
|
|
234
246
|
image: mentorayush/wico-app:latest
|
|
@@ -243,6 +255,12 @@ services:
|
|
|
243
255
|
- node-server
|
|
244
256
|
networks:
|
|
245
257
|
- freeschema-network
|
|
258
|
+
healthcheck:
|
|
259
|
+
test: ["CMD-SHELL", "wget -q --spider http://localhost/ || exit 1"]
|
|
260
|
+
interval: 30s
|
|
261
|
+
timeout: 10s
|
|
262
|
+
retries: 3
|
|
263
|
+
start_period: 30s
|
|
246
264
|
|
|
247
265
|
nginx-server:
|
|
248
266
|
image: nginx:alpine
|
|
@@ -255,13 +273,20 @@ services:
|
|
|
255
273
|
volumes:
|
|
256
274
|
- ./nginx/nginx.conf.template:/etc/nginx/templates/default.conf.template:ro
|
|
257
275
|
depends_on:
|
|
258
|
-
-
|
|
259
|
-
|
|
260
|
-
-
|
|
261
|
-
|
|
262
|
-
-
|
|
263
|
-
|
|
264
|
-
-
|
|
276
|
+
access-control-server:
|
|
277
|
+
condition: service_healthy
|
|
278
|
+
wico-server:
|
|
279
|
+
condition: service_healthy
|
|
280
|
+
node-server:
|
|
281
|
+
condition: service_healthy
|
|
282
|
+
node-cache-server:
|
|
283
|
+
condition: service_healthy
|
|
284
|
+
log-server:
|
|
285
|
+
condition: service_healthy
|
|
286
|
+
vccs-app:
|
|
287
|
+
condition: service_healthy
|
|
288
|
+
wico-app:
|
|
289
|
+
condition: service_healthy
|
|
265
290
|
networks:
|
|
266
291
|
- freeschema-network
|
|
267
292
|
|