-
Notifications
You must be signed in to change notification settings - Fork 645
Enable FastBoot #1715
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
Merged
Merged
Enable FastBoot #1715
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
60a7f4c
Add ember-cli-fastboot and upgrade dependencies
kzys e0a032a
Enable Fastboot
kzys 9461add
Use node-foreman to run Node with Rust
kzys 9409a96
Fix /crates/$crate_id
kzys 21658ec
Testem adds own title element which breaks document.title
kzys 07360be
Fix eslint
kzys 820a41d
Don't use .ember-application which is added after FastBoot
kzys 3753a2c
npm install --save fastboot-app-server
kzys a78d12f
Fix Acceptance Tests
kzys cff7481
Write /tmp/app-initialized from Fastboot-side
kzys ddfeed7
Forward only /policies page
kzys cee1354
Remove timestamps from node-foreman
kzys 82c84d0
Remove timestamps from fastboot-app-server
kzys 5803188
Fix prettier errors
kzys 56f23f1
Don't remove the noscript message
kzys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
release: bin/diesel migration run | ||
web: bin/start-nginx ./target/release/server | ||
web: bin/start-nginx npm run nf -- --procfile foreman-procfile start --raw | ||
background_worker: ./target/release/background-worker |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* eslint-disable no-console */ | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const FastBootAppServer = require('fastboot-app-server'); | ||
|
||
// because fastboot-app-server uses cluster, but it might change in future | ||
const cluster = require('cluster'); | ||
|
||
class LoggerWithoutTimestamp { | ||
constructor() { | ||
this.prefix = cluster.isMaster ? 'master' : 'worker'; | ||
} | ||
writeLine() { | ||
this._write('info', Array.prototype.slice.apply(arguments)); | ||
} | ||
|
||
writeError() { | ||
this._write('error', Array.prototype.slice.apply(arguments)); | ||
} | ||
|
||
_write(level, args) { | ||
args[0] = `[${level}][${this.prefix}] ${args[0]}` | ||
console.log.apply(console, args) | ||
} | ||
} | ||
|
||
function writeAppInitializedWhenReady(logger) { | ||
let timeout; | ||
|
||
timeout = setInterval(function() { | ||
logger.writeLine('waiting backend'); | ||
if (fs.existsSync('/tmp/backend-initialized')) { | ||
logger.writeLine('backend is up. let heroku know the app is ready'); | ||
fs.writeFileSync('/tmp/app-initialized', 'hello'); | ||
clearInterval(timeout); | ||
} else { | ||
logger.writeLine('backend is still not up'); | ||
} | ||
}, 1000); | ||
} | ||
|
||
var logger = new LoggerWithoutTimestamp(); | ||
|
||
let server = new FastBootAppServer({ | ||
distPath: 'dist', | ||
port: 9000, | ||
ui: logger | ||
}); | ||
|
||
if (!cluster.isWorker) { | ||
writeAppInitializedWhenReady(logger); | ||
} | ||
|
||
server.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default { | ||
name: 'ajax-service', | ||
initialize() { | ||
// This is to override Fastboot's initializer which prevents ember-fetch from working | ||
// https://github.com/ember-fastboot/ember-cli-fastboot/blob/master/fastboot/initializers/ajax.js | ||
// https://github.com/ember-cli/ember-fetch#ajax-service | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ember: node fastboot.js | ||
api: ./target/release/server |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing a final pass on these changes, I'm not sure if we should remove this notice at this time. We'll want to make sure users hitting URLs other than
/policy
see this. Is there a way to only remove this when rendering in fastboot?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Let me restore the warning for now. index.html cannot use Handlerbars apparently. So checking FastBoot from here seems tricky.