freeschema 1.0.10 → 1.0.12

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 (2) hide show
  1. package/bin/freeschema.js +25 -14
  2. package/package.json +1 -1
package/bin/freeschema.js CHANGED
@@ -122,9 +122,18 @@ function generateMosquittoPassword(username, password) {
122
122
  return `${username}:$7$${iterations}$${salt.toString('base64')}$${hash.toString('base64')}\n`;
123
123
  }
124
124
 
125
+ function isContainerHealthy(containerName) {
126
+ const r = spawnSync('docker', [
127
+ 'inspect', '--format', '{{.State.Health.Status}}', containerName
128
+ ], { stdio: 'pipe' });
129
+ return (r.stdout || '').toString().trim() === 'healthy';
130
+ }
131
+
125
132
  function waitForAccessControl(container) {
133
+ if (isContainerHealthy(container)) return true; // already healthy — no wait needed
126
134
  process.stdout.write(' Waiting for access-control-server');
127
- for (let i = 0; i < 30; i++) {
135
+ for (let i = 0; i < 60; i++) { // 60 × 2s = 120s
136
+ if (isContainerHealthy(container)) { process.stdout.write(' ready\n'); return true; }
128
137
  const r = spawnSync('docker', [
129
138
  'exec', container, 'curl', '-sf', 'http://localhost:7000/health'
130
139
  ], { stdio: 'pipe' });
@@ -147,7 +156,10 @@ function setupSuperAdmin() {
147
156
  if (!ac) return;
148
157
  const container = ac.Name || ac.ID;
149
158
 
150
- if (!waitForAccessControl(container)) return;
159
+ if (!isContainerHealthy(container)) {
160
+ console.log(' Super admin will be set on next start (access-control still starting)');
161
+ return;
162
+ }
151
163
 
152
164
  const result = spawnSync('docker', [
153
165
  'exec', container, 'curl', '-sf',
@@ -600,21 +612,18 @@ async function cmdStart() {
600
612
  console.log('\nFinalizing setup…');
601
613
  setupSuperAdmin();
602
614
 
603
- console.log('\nFreeSchema is running.');
604
- console.log(' Status: freeschema status');
605
- console.log(' Logs: freeschema logs');
606
- console.log(' Stop: freeschema stop');
607
-
608
- // Auto-setup credentials if CLIENT_SECRET is missing or placeholder
609
615
  const envAfterStart = readEnv();
610
616
  const clientSecret = envAfterStart.CLIENT_SECRET || '';
611
- const isPlaceholder = clientSecret === '' || clientSecret === 'sk_test_placeholder';
617
+ const isPlaceholder = !clientSecret || clientSecret === 'sk_test_placeholder';
618
+
619
+ console.log('\nFreeSchema is running.');
620
+ console.log(' Status: freeschema status');
621
+ console.log(' Logs: freeschema logs');
622
+ console.log(' Stop: freeschema stop');
612
623
  if (isPlaceholder) {
613
- console.log('\n─────────────────────────────────────────');
614
- console.log(' CLIENT_SECRET is not configured.');
615
- console.log(' Setting up admin credentials');
616
- console.log('─────────────────────────────────────────');
617
- await cmdSetupCredentials();
624
+ console.log('\n CLIENT_SECRET is not set yet.');
625
+ console.log(' Once services are healthy, run:');
626
+ console.log(' freeschema setup-credentials');
618
627
  }
619
628
  }
620
629
 
@@ -770,8 +779,10 @@ function getWicoContainer() {
770
779
  }
771
780
 
772
781
  function waitForWicoServer(container, maxAttempts = 60) {
782
+ if (isContainerHealthy(container)) return true; // already healthy — no wait needed
773
783
  process.stdout.write(' Waiting for wico-server');
774
784
  for (let i = 0; i < maxAttempts; i++) {
785
+ if (isContainerHealthy(container)) { process.stdout.write(' ready\n'); return true; }
775
786
  const r = spawnSync('docker', [
776
787
  'exec', container, 'curl', '-sf', 'http://localhost:7000/health'
777
788
  ], { stdio: 'pipe' });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freeschema",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "FreeSchema — self-hosted deployment CLI",
5
5
  "keywords": [
6
6
  "freeschema",