Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update spin up to spin watch so npm run spin works. #1284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tpmccallum
Copy link
Contributor

@tpmccallum tpmccallum commented May 10, 2024

Signed-off-by: tpmccallum [email protected]

Fixes #849

Before:

$ npm run spin

> [email protected] spin /home/tpmccallum/Fermyon/developer
> nodemon --watch content --watch static --watch templates --watch spin-up-hub --ext html,md,rhai,hbs,css,js --verbose --legacy-watch --signal SIGINT --exec 'npm run build-index && npm run build-hub-index && spin up --file spin.toml --quiet --env PREVIEW_MODE=$PREVIEW_MODE'

[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGUSR2 to 2615137 to restart
[nodemon] watching path(s): content/**/* static/**/* templates/**/* spin-up-hub/**/*
[nodemon] watching extensions: html,md,rhai,hbs,css,js
[nodemon] starting `npm run build-index && npm run build-hub-index && spin up --file spin.toml --quiet --env PREVIEW_MODE=$PREVIEW_MODE`
[nodemon] spawning
[nodemon] child pid: 2615159
[nodemon] watching 489 files

> [email protected] build-index /home/tpmccallum/Fermyon/developer
> node md_parser.mjs --dir=./content/ --out=./static/data.json --ignore=./content/api/**/*

[nodemon] files triggering change check: static/data.json
[nodemon] matched rule: /home/tpmccallum/Fermyon/developer/static/**/*
[nodemon] changes after filters (before/after): 1/0

> [email protected] build-hub-index /home/tpmccallum/Fermyon/developer
> node hub_index_generator.mjs --dir=./content/api/hub/ --out=./static/hub-index-data.json --ignore=./content/api/hub/get_list.md,

[nodemon] files triggering change check: static/hub-index-data.json
[nodemon] matched rule: /home/tpmccallum/Fermyon/developer/static/**/*
[nodemon] changes after filters (before/after): 1/0
Error: Failed to load manifest from "spin.toml"

Caused by:
   0: Failed to load Spin app from "spin.toml"
   1: Failed to load component `hub-fileserver-static`
   2: File or directory "spin-up-hub/dist/" does not exist
[nodemon] app crashed - waiting for file changes before starting...

Signed-off-by: tpmccallum [email protected]

Signed-off-by: Timothy McCallum <[email protected]>
Copy link

🚀 preview deployed successfully to Fermyon Cloud and available at https://fermyon-developer-pr-1284-qrcubjnh.fermyon.app

@tpmccallum
Copy link
Contributor Author

tpmccallum commented May 10, 2024

Perhaps there is more to this than meets the eye.

Worked the first and second time but failing consistently now:

✓ built in 5.75s
[nodemon] files triggering change check: spin-up-hub/dist/assets/index-a80a27fc.js
[nodemon] matched rule: /home/tpmccallum/Fermyon/developer/spin-up-hub/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] spin-up-hub/dist/assets/index-a80a27fc.js

[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...
[nodemon] still waiting for 1 sub-process to finish...

@@ -37,7 +37,7 @@
"yaml-front-matter": "^4.1.1"
},
"scripts": {
"spin": "nodemon --watch content --watch static --watch templates --watch spin-up-hub --ext html,md,rhai,hbs,css,js --verbose --legacy-watch --signal SIGINT --exec 'npm run build-index && npm run build-hub-index && spin up --file spin.toml --quiet --env PREVIEW_MODE=$PREVIEW_MODE'",
"spin": "nodemon --watch content --watch static --watch templates --watch spin-up-hub --ext html,md,rhai,hbs,css,js --verbose --legacy-watch --signal SIGINT --exec 'npm run build-index && npm run build-hub-index && spin watch --file spin.toml --quiet --env PREVIEW_MODE=$PREVIEW_MODE'",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need both spin watch and spin up. They effectively serve the same purpose of restartting. We got to choose one or the other,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @karthik2804
Not sure I understand. There is only one spin command in the package.json (spin watch) so as far as I can tell after this update the site will exclusively use spin watch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a typo for not needing both spin watch and nodemon --watch. If nodemon is already watching, it shouldn't be telling Spin to watch, just to run. Conversely, if both are watching, spin watch get as far as going "oh there's a change I better restart spin up" and then nodemon will swoop in and kills it.

@karthik2804
Copy link
Contributor

Perhaps an even better idea for this would be to use, spin up --direct-mounts that would make the cycle much faster instead of restarting spin. We could just have nodemon watch for rebuilding the search index.

cc: @itowlson for viz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make npm run spin build the hub
3 participants