Revel does NOT have connection/resource management and all production deployments should have a HTTP proxy that is properly configured in front of all Revel HTTP requests.

Overview

There are a couple common deployment routes:

Build locally

Revel apps may be deployed to machines that do not have a functioning Goinstallation. The command line tool provides the package commandwhich compiles and zips the app, along with a script to run it.

  1. # Run and test my app.
  2. $ revel run import/path/to/app
  3. .. test app ..
  4. # Package it up.
  5. $ revel package import/path/to/app
  6. Your archive is ready: app.tar.gz
  7. # Copy to the target machine.
  8. $ scp app.tar.gz target:/srv/
  9. # Run it on the target machine.
  10. $ ssh target
  11. $ cd /srv/
  12. $ tar xzvf app.tar.gz
  13. $ bash run.sh

This only works if you develop and deploy to the same architecture, or if you configure your goinstallation to build to the desired architecture by default. See below for cross-compilation support.

Incremental deployment

Since a statically-linked binary with a full set of assets can grow to be quitelarge, incremental deployment is supported.

  1. # Build the app into a temp directory
  2. $ revel build import/path/to/app /tmp/app
  3. # Rsync that directory into the home directory on the server
  4. $ rsync -vaz --rsh="ssh" /tmp/app server
  5. # Connect to server and restart the app.
  6. ...

Rsync has full support for copying over ssh. For example, here’s a more complicated connection.

  1. # A more complicated example using custom certificate, login name, and target directory
  2. $ rsync -vaz --rsh="ssh -i .ssh/go.pem" /tmp/myapp2 ubuntu@ec2-50-16-80-4.compute-1.amazonaws.com:~/rsync

Build on the server

This method relies on your version control system to distribute updates. Itrequires your server to have a Go installation. In return, it allows you toavoid potentially having to cross-compile.

  1. $ ssh server
  2. ... install go ...
  3. ... configure your app repository ...
  4. # Move to the app directory (in your GOPATH), pull updates, and run the server.
  5. $ cd gocode/src/import/path/to/app
  6. $ git pull
  7. $ revel run import/path/to/app prod

Heroku

Revel maintains a Heroku Buildpack, allowing one-command deploys.

Boxfuse comes with first-class support for Revel apps with one-command deploys to AWS.

In order to create a cross-compile environment, you need to build go from source.SeeInstalling Go from sourcefor more information.You must properly set your $PATH and $GOPATH variables, otherwise if there is an existingbinary Go package, you will get into serious errors.

When you have a go compiler successfully setup, build the cross-compiler byspecifying the target environment with GOOS and GOARCH environment variables. SeeOptional environment variablesfor more information.

  1. $ cd /path/to/goroot/src
  2. $ GOOS=linux GOARCH=amd64 ./make.bash --no-clean
  3. $ GOOS=windows GOARCH=386 ./make.bash --no-clean

Install revel on the new environment and you are set to go with the packaging.

  1. $ GOOS=linux GOARCH=amd64 revel package import/path/to/app

Copy the resulting tarball to your target platform.

原文: https://revel.github.io/manual/deployment.html