somratpro Claude Haiku 4.5 commited on
Commit
dcedf5f
·
1 Parent(s): 9cb2a61

fix: 503 health check, backup dataset creation, auto bootstrap-ceo

Browse files

- Fix nextSync: string+number concat caused Invalid Date -> toISOString throw -> 503
- Fix backup: always call create_repo(exist_ok=True) before uploading
- Add bootstrap-ceo step to generate first admin invite URL at startup

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

Files changed (3) hide show
  1. health-server.js +1 -1
  2. paperclip-sync.py +3 -6
  3. start.sh +14 -0
health-server.js CHANGED
@@ -57,7 +57,7 @@ app.get("/health", async (req, res) => {
57
  lastSync: syncStatus.last_sync_time,
58
  nextSync: syncStatus.last_sync_time
59
  ? new Date(
60
- syncStatus.last_sync_time +
61
  parseInt(process.env.SYNC_INTERVAL || 180) * 1000,
62
  ).toISOString()
63
  : null,
 
57
  lastSync: syncStatus.last_sync_time,
58
  nextSync: syncStatus.last_sync_time
59
  ? new Date(
60
+ new Date(syncStatus.last_sync_time).getTime() +
61
  parseInt(process.env.SYNC_INTERVAL || 180) * 1000,
62
  ).toISOString()
63
  : null,
paperclip-sync.py CHANGED
@@ -220,12 +220,9 @@ def sync_to_hf(backup_file: str) -> bool:
220
 
221
  dataset_id = f'{username}/{BACKUP_DATASET_NAME}'
222
 
223
- # Create dataset if it doesn't exist
224
- try:
225
- logger.info(f'Using dataset: {dataset_id}')
226
- except RepositoryNotFoundError:
227
- logger.info(f'Creating dataset: {dataset_id}')
228
- api.create_repo(repo_id=dataset_id, repo_type='dataset', private=True, exist_ok=True)
229
 
230
  # Upload file
231
  api.upload_file(
 
220
 
221
  dataset_id = f'{username}/{BACKUP_DATASET_NAME}'
222
 
223
+ # Ensure dataset exists (creates private dataset on first run)
224
+ api.create_repo(repo_id=dataset_id, repo_type='dataset', private=True, exist_ok=True)
225
+ logger.info(f'Using dataset: {dataset_id}')
 
 
 
226
 
227
  # Upload file
228
  api.upload_file(
start.sh CHANGED
@@ -250,5 +250,19 @@ cleanup() {
250
 
251
  trap cleanup SIGTERM SIGINT
252
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  # Start Paperclip server with tsx loader (loads workspace .ts packages at runtime)
254
  exec node --import ./server/node_modules/tsx/dist/loader.mjs server/dist/index.js
 
250
 
251
  trap cleanup SIGTERM SIGINT
252
 
253
+ # Generate first admin invite URL if no admin exists yet
254
+ # Runs against the database directly (no server needed) and prints the URL to logs
255
+ echo -e "${BLUE}[8/8] Bootstrapping admin account...${NC}"
256
+ BOOTSTRAP_OUTPUT=$(pnpm paperclipai auth bootstrap-ceo 2>&1)
257
+ if echo "$BOOTSTRAP_OUTPUT" | grep -qi "invite\|http\|url\|link"; then
258
+ echo -e "${GREEN}✓ Admin invite URL:${NC}"
259
+ echo "$BOOTSTRAP_OUTPUT"
260
+ echo -e "${YELLOW}Copy the URL above to complete first-time setup.${NC}\n"
261
+ elif echo "$BOOTSTRAP_OUTPUT" | grep -qi "already\|exists\|skip"; then
262
+ echo -e "${GREEN}✓ Admin account already exists${NC}\n"
263
+ else
264
+ echo -e "${YELLOW}Bootstrap output: ${BOOTSTRAP_OUTPUT}${NC}\n"
265
+ fi
266
+
267
  # Start Paperclip server with tsx loader (loads workspace .ts packages at runtime)
268
  exec node --import ./server/node_modules/tsx/dist/loader.mjs server/dist/index.js