如何将我的Spray API部署到生产中? [英] How to deploy my spray API into production?

查看:79
本文介绍了如何将我的Spray API部署到生产中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将经过本地测试的剩余api部署到云中的过程应该如何,可以说像亚马逊这样的基础设施即服务(而不是像Heroku这样的平台即服务)。

I'm thinking about how should be the process to deploy my already locally tested rest api to the cloud, lets say an infrastructure as a service (not a platform as a service such as Heroku) like amazon.

我已经设置并运行了sbt,但我的问题是我应该如何在生产环境中部署它?

I have my local envorinment set up with sbt up and running but my question is How should I deploy this in a production environment?

定义一个进程,让devops从git repo中提取最新更改,然后简单地执行sbt run是明智的吗?

Is it sane to define a process in which the devops pulls the most recent changes from the git repo and then simply executes sbt run?

我想知道如何使用scala + spray + sbt的团队将其api部署到生产环境。

I want to know how does the teams that uses scala+spray+sbt deploys their apis to a production environment.

推荐答案

我们服务的核心是scala + Akka +喷雾剂+ Mongo。因此,我们使用GitHub进行版本控制。将已检查的PR合并到master分支后,Jenkins自动测试n的builds项目。如果所有测试都成功,那么Jenking将运行几个脚本:

The heart of our services is scala + akka + spray + mongo. So we are using GitHub for version control. After merging checked PRs to the master branch, Jenkins automaticaly tests'n'builds project. If all tests were successful then Jenking runs a couple of scripts:


  1. 递增项目版本(当前以shell编写,但将更改为sbt )

  2. 使用 sbt-assembly
  3. $ b $运行组装任务b
  4. 运行部署脚本(用Fabric与Python一起编写),将我们的jar部署到EC2

基本步骤已完成几个选择:

Basicaly on the thrid step you have a couple of choices:

使用IO / Spray引导文件制作可运行的jar:

object Boot extends App {
  implicit val system = ActorSystem("ServiceName")
  val log = system.log
  val service = system.actorOf(Props[Service], name="serviceActor")
  IO(Http) ! Http.Bind(service, interface = host, port = port)
}

将可运行的jar用作Akka的微内核:

在这种情况下,您应该扩展Bootable特质并覆盖 startup 关机方法:

In this case you should extend Bootable trait and override startup and shutdown methods:

class Kernel extends Bootable {
  // many lines of code
  def startup() {
    scheduler.start()
    SomeActorSystem.startup()
  }

  def shutdown() {
    scheduler.shutdown()
    SomeActorSystem.shutdown()
    system.shutdown()
  }
}

使用TypeSafe起始脚本:

无法显示一个例子,但是它对 github =)

Can't show an example, but it has a good intro on github =)

我们在不同情况下都使用了这种方式。

We are using all of this way in different cases.

这篇关于如何将我的Spray API部署到生产中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆