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

Support unix socket or port for functions server #1689

Merged
merged 5 commits into from
Feb 4, 2021

Conversation

brentjanderson
Copy link
Contributor

I'm trying to get instructions together to run Redwood on Heroku. Given that half of the app runs as a statically built site and the other half runs with @redwoodjs/api-server, I'm planning on doing the following:

  1. Add a build script to the root package.json yarn rw build
  2. Have a release phase that runs yarn rw db up
  3. Have a modified "start" script that fires up the api-server using a UNIX Socket (because that's what Heroku lets you work with when you want to run multiple backends from a single frontend Nginx server)
  4. Use the Heroku NGINX buildpack and point it at that unix socket for the API and the built web HTML

This PR enables step 3. If you specify --socket then it will mount it on that local socket instead of a given port. On process exit, we clean up the socket. The other changes would be made by teams wanting to deploy to heroku.

@github-actions
Copy link

github-actions bot commented Jan 28, 2021

@peterp
Copy link
Contributor

peterp commented Jan 28, 2021

This is awesome, thanks!

@brentjanderson
Copy link
Contributor Author

@peterp I missed putting the process.on('exit', ... around the app.close. Should exhibit the expected behavior now.

@brentjanderson
Copy link
Contributor Author

As a follow-on to this, I've got the bare bones of a guide for running Redwood on Heroku here: https://gist.github.com/brentjanderson/dcb59c46023c67c44eb12492b038ff84

I've got it working on an internal app built with Redwood and running on Heroku. I haven't had someone try and use those instructions themselves yet to proof that they're workable, but it's pretty straightforward once this PR lands and if you add in the right pieces for heroku (Nginx conf file, Procfile, app.json, build/start script, etc.)

Comments there welcome - I'll drop a note on the forum as well for feedback.

@Tobbe
Copy link
Member

Tobbe commented Feb 1, 2021

I'll drop a note on the forum as well for feedback.

Great idea! 👍

@brentjanderson
Copy link
Contributor Author

@dac09 dac09 added this to the v0.25.0 milestone Feb 4, 2021
@thedavidprice thedavidprice merged commit a22685d into redwoodjs:main Feb 4, 2021
@brentjanderson brentjanderson deleted the support-unix-sockets branch February 4, 2021 21:19
dac09 added a commit to dac09/redwood that referenced this pull request Feb 5, 2021
…ender-p1

* 'main' of github.com:redwoodjs/redwood:
  Updated Status of Storybook in Technologies
  Fix import in RWProject in rw/structure (redwoodjs#1707)
  Support unix socket or port for functions server (redwoodjs#1689)
  Don't run PR build actions on forks (redwoodjs#1712)
  Router: Explicitly build types (redwoodjs#1722)
  Router: Automatically import .ts Page files
  Fix env loading in users webpack config (redwoodjs#1729)
  Format import-dir-*-.d.ts
  Format generated routes.d.ts file
  CRWA Readme: Add missing comma (redwoodjs#1715)
  Corrects dataMigrate install instructions (redwoodjs#1718)
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.

None yet

5 participants