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

ember fastboot --watch #200

Merged
merged 3 commits into from
Jun 17, 2016
Merged

ember fastboot --watch #200

merged 3 commits into from
Jun 17, 2016

Conversation

pwfisher
Copy link
Contributor

@rwjblue Tests coming soon, just want to open the PR for some early feedback. Does this approach look reasonable?

@danmcclain
Copy link
Member

I'd argue that ember fastboot should watch by default like ember serve does

@pwfisher
Copy link
Contributor Author

I'm thinking SIGHUP would be more appropriate than SIGUSR1.

For this reason, applications that did not require a controlling terminal, such as daemons, would re-purpose SIGHUP as a signal to re-read configuration files, or reinitialize. This convention survives to this day in packages such as Apache and Sendmail. [Wikipedia]

@pwfisher pwfisher changed the title ember fastboot --watch [WIP] ember fastboot --watch May 25, 2016

ui.writeLine("Installing FastBoot npm dependencies");
if (this._fastBootListener) {
Copy link
Contributor

@jasonmit jasonmit May 25, 2016

Choose a reason for hiding this comment

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

I recall some issues in the past where programmatically restarting a server required I also flush require.cache otherwise stale modules were loaded. I could be wrong, just jotting down something that came to mind.

Likely only a cause for concern if we plan to support adding custom middleware.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I'm adding that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue would affect dist/fastboot/node_modules, which we require in buildWhitelistedRequire

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

unit tests for lib/commands/fastboot
@pwfisher pwfisher changed the title [WIP] ember fastboot --watch ember fastboot --watch May 27, 2016
@leo
Copy link

leo commented May 29, 2016

@danmcclain Great idea! And it should be disabled if the --environment flag is set to "production".

@stefanpenner
Copy link
Contributor

I would really like it if fastboot and normal serve could be united during development. An early discussion I started about making app.js the same regardless of fastboot or browser would nicely enable this.

@danmcclain
Copy link
Member

@stefanpenner We actually talked about this during the last FastBoot Sync meeting

return;
}
debug('restart');
this.restartPromise = this.stop()
Copy link
Member

Choose a reason for hiding this comment

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

I think we should try to avoid stopping and starting the server for each reload. With some tweaks to our usage of fastboot-express-middleware we should be able to make this restartPromise closer to:

this.restartPromise = RSVP.resolve()
  .then(() => this.clearRequireCache(options.outputPath))
  .then(() => this._fastboot.reload())
  .finally(() => { /* snip from existing */ })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Faster restart will be a separate task.

@rwjblue
Copy link
Member

rwjblue commented Jun 15, 2016

I left a few inline comments, but overall this looks very good.

Also, stylistic nit RE: const: I'd prefer to stay in line with Ember and only use const in module scope.

@pwfisher
Copy link
Contributor Author

Per discussion, we will leave the npm install on restart since it will "just work" and potential optimization will be complex (dist/node_modules is nuked by the build and the naïve solution would rely on require finding its dependencies up the directory tree—but this is not guaranteed to work). An optimized restart would be a separate PR.

const usage can land as-is and a separate PR will add and apply the linter rules from Ember.

@danmcclain
Copy link
Member

I'm going to add homu.io use that to merge this, will do so tonight

@danmcclain danmcclain merged commit 1635d68 into ember-fastboot:master Jun 17, 2016
@danmcclain
Copy link
Member

Homu has been dead for days 😢

xg-wang pushed a commit to xg-wang/ember-cli-fastboot that referenced this pull request Nov 16, 2020
Allow to require module path from whitelisted dependency
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.

6 participants