- 浏览: 2560898 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Docker Normal Akka Application
1 Configuration Setting
First of all, I am using a normal Akka system application. It is not spray, not play framework. So how to work on the configuration, that is the first question.
I am using a trait to handle the configuration, all the configuration should be here.
package com.sillycat.jobsconsumer.utilities
import com.typesafe.config._
trait IncludeConfig extends IncludeLogger{
val config = ConfigFactory.load()
/** all the configuration */
/** third-party service */
val classifierEndpoint = config.getString("api.classifier.endpoint")
val geoServerEndpoint = config.getString("api.geoserver.endpoint")
/** actor related */
val actorRawJobCount = config.getInt("actor.supervisor.rawjob.count")
val actorRedisJobCount = config.getInt("actor.supervisor.redisjob.count")
val actorSolrJobCount = config.getInt("actor.supervisor.solrjob.count")
val actorPullingDurationMax = config.getInt("actor.supervisor.pulling.duration.max")
}
In the src/main/resources/, I have these configuration files.
application-local.conf
application.conf
The parameters to pick up the configuration file and log4j file.
-Dconfig.file=conf/application-stage.conf -Dlog4j.configuration=file:conf/log4j-stage.properties
2 Log4j Configuration
Just normal log4j configuration
log4j.rootCategory=WARN,stdout, R
# rolling log file ("jobs-consumer.log")
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
log4j.appender.R.File=logs/jobs-consumer.log
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
# Device unregistration settings
log4j.logger.com.sillycat.jobsconsumer=DEBUG
log4j.logger.com.sillycat.services=DEBUG
It will be like this log4j-stage.properties, log4j.properties.
Command will be as follow parameters.
-Dconfig.file=conf/application-stage.conf -Dlog4j.configuration=file:conf/log4j-stage.properties
3 Build.sbt to Build Release
Plugins Configuration
logLevel := Level.Warn
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.6")
build.sbt Configuration
enablePlugins(JavaServerAppPackaging)
name := "jobs-consumer"
version := "1.0"
//for redis testing
resolvers += "rediscala" at "http://dl.bintray.com/etaty/maven"
//for solr-core testing
resolvers += "Restlet Repositories" at "http://maven.restlet.org"
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk" % "1.10.6", //
"org.slf4j" % "slf4j-api" % "1.7.12", // MIT
"org.slf4j" % "slf4j-log4j12" % "1.7.12",
"com.typesafe" % "config" % "1.3.0",
"com.etaty.rediscala" %% "rediscala" % "1.4.2",
"org.msgpack" % "msgpack" % "0.6.12",
"org.apache.solr" % "solr-solrj" % "5.3.0",
"mysql" % "mysql-connector-java" % "5.1.36",
"com.thoughtworks.xstream" % "xstream" % "1.4.8",
"commons-lang" % "commons-lang" % "2.6", //html escape
"org.joda" % "joda-convert" % "1.7",
"com.gu" %% "prequel" % "0.3.12",
"io.spray" %% "spray-client" % "1.3.1",
"io.spray" %% "spray-can" % "1.3.1",
"io.spray" %% "spray-http" % "1.3.1",
"io.spray" %% "spray-httpx" % "1.3.1",
"io.spray" %% "spray-util" % "1.3.1",
"io.spray" %% "spray-json" % "1.3.1",
"com.typesafe.akka" %% "akka-actor" % "2.3.2",
"com.typesafe.akka" %% "akka-testkit" % "2.3.2",
"com.typesafe.akka" %% "akka-transactor" % "2.3.2",
"com.typesafe.akka" %% "akka-kernel" % "2.3.2",
"com.google.guava" % "guava" % "19.0",
"com.google.code.findbugs" % "jsr305" % "3.0.1",
"org.scalatest" %% "scalatest" % "2.2.0" % "test", // Apache v2
"org.mockito" % "mockito-all" % "1.9.5" % "test", // MIT
"com.orange.redis-embedded" % "embedded-redis" % "0.6" % "test",
"org.apache.solr" % "solr-core" % "5.3.0" % "test"
)
mainClass in Compile := Some("com.sillycat.jobsconsumer.ServerBoot")
mappings in Universal ++= {
val base = baseDirectory.value
val confDir = base / "src" / "main" / "resources"
for {
(file, relativePath) <- (confDir.** ("*.conf" || "*.properties") --- confDir) x relativeTo(confDir)
} yield file -> s"conf/$relativePath"
}
After doing that, this command can generate the binary file.
>sbt clean update compile package universal:packageZipTarball
The docker related configuration will be as follow:
Dockerfile
#Run a Simple REST API based on playframework
#Prepre the OS
FROM centos:7
MAINTAINER Carl Luo <luohuazju@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
#Install Java
RUN yum install -y java-1.8.0-openjdk
#Install the Application
RUN mkdir /share/
WORKDIR /share/
ADD target/universal/jobs-consumer-1.0.tgz /share/
#Start the Application
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app
CMD [ "./start.sh" ]
Makefile
IMAGE=sillycat/jobs-consumer
TAG=1.0
NAME=jobs-consumer
REPOSITORY=registry.sillycat.com
push-local:
docker push $(REPOSITORY)/$(IMAGE):$(TAG)
app-build:
sbt clean update compile package universal:packageZipTarball
docker-context:
build: docker-context
sudo docker build -t $(REPOSITORY)/$(IMAGE):$(TAG) .
run-stage:
sudo docker run -v /opt/jobs-consumer/logs:/share/jobs-consumer-1.0/logs -d -e RUNNING_ENV=stage --name $(NAME) $(REPOSITORY)/$(IMAGE):$(TAG)
debug:
sudo docker run -v /opt/jobs-consumer/logs:/share/jobs-consumer-1.0/logs -ti -e RUNNING_ENV=stage --name $(NAME) $(REPOSITORY)/$(IMAGE):$(TAG) /bin/bash
clean:
sudo docker stop ${NAME}
sudo docker rm ${NAME}
logs:
sudo docker logs ${NAME}
publish:
sudo docker push ${IMAGE}
start.sh
#!/bin/sh -ex
APPLICATION_SECRET="nosessionshere"
cd /share/jobs-consumer-1.0
bin/jobs-consumer \
-Dconfig.file=conf/application-${RUNNING_ENV}.conf \
-Dlog4j.configuration=file:conf/log4j-${RUNNING_ENV}.properties
References:
http://sillycat.iteye.com/blog/2123896
https://github.com/muuki88/sbt-native-packager-examples
https://github.com/muuki88/sbt-native-packager-examples/tree/master/assembly-one-jar
1 Configuration Setting
First of all, I am using a normal Akka system application. It is not spray, not play framework. So how to work on the configuration, that is the first question.
I am using a trait to handle the configuration, all the configuration should be here.
package com.sillycat.jobsconsumer.utilities
import com.typesafe.config._
trait IncludeConfig extends IncludeLogger{
val config = ConfigFactory.load()
/** all the configuration */
/** third-party service */
val classifierEndpoint = config.getString("api.classifier.endpoint")
val geoServerEndpoint = config.getString("api.geoserver.endpoint")
/** actor related */
val actorRawJobCount = config.getInt("actor.supervisor.rawjob.count")
val actorRedisJobCount = config.getInt("actor.supervisor.redisjob.count")
val actorSolrJobCount = config.getInt("actor.supervisor.solrjob.count")
val actorPullingDurationMax = config.getInt("actor.supervisor.pulling.duration.max")
}
In the src/main/resources/, I have these configuration files.
application-local.conf
application.conf
The parameters to pick up the configuration file and log4j file.
-Dconfig.file=conf/application-stage.conf -Dlog4j.configuration=file:conf/log4j-stage.properties
2 Log4j Configuration
Just normal log4j configuration
log4j.rootCategory=WARN,stdout, R
# rolling log file ("jobs-consumer.log")
log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.DatePattern='.'yyyy-MM-dd
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
log4j.appender.R.File=logs/jobs-consumer.log
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] %d{ISO8601} %F (line %L) %m%n
# Device unregistration settings
log4j.logger.com.sillycat.jobsconsumer=DEBUG
log4j.logger.com.sillycat.services=DEBUG
It will be like this log4j-stage.properties, log4j.properties.
Command will be as follow parameters.
-Dconfig.file=conf/application-stage.conf -Dlog4j.configuration=file:conf/log4j-stage.properties
3 Build.sbt to Build Release
Plugins Configuration
logLevel := Level.Warn
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.6")
build.sbt Configuration
enablePlugins(JavaServerAppPackaging)
name := "jobs-consumer"
version := "1.0"
//for redis testing
resolvers += "rediscala" at "http://dl.bintray.com/etaty/maven"
//for solr-core testing
resolvers += "Restlet Repositories" at "http://maven.restlet.org"
libraryDependencies ++= Seq(
"com.amazonaws" % "aws-java-sdk" % "1.10.6", //
"org.slf4j" % "slf4j-api" % "1.7.12", // MIT
"org.slf4j" % "slf4j-log4j12" % "1.7.12",
"com.typesafe" % "config" % "1.3.0",
"com.etaty.rediscala" %% "rediscala" % "1.4.2",
"org.msgpack" % "msgpack" % "0.6.12",
"org.apache.solr" % "solr-solrj" % "5.3.0",
"mysql" % "mysql-connector-java" % "5.1.36",
"com.thoughtworks.xstream" % "xstream" % "1.4.8",
"commons-lang" % "commons-lang" % "2.6", //html escape
"org.joda" % "joda-convert" % "1.7",
"com.gu" %% "prequel" % "0.3.12",
"io.spray" %% "spray-client" % "1.3.1",
"io.spray" %% "spray-can" % "1.3.1",
"io.spray" %% "spray-http" % "1.3.1",
"io.spray" %% "spray-httpx" % "1.3.1",
"io.spray" %% "spray-util" % "1.3.1",
"io.spray" %% "spray-json" % "1.3.1",
"com.typesafe.akka" %% "akka-actor" % "2.3.2",
"com.typesafe.akka" %% "akka-testkit" % "2.3.2",
"com.typesafe.akka" %% "akka-transactor" % "2.3.2",
"com.typesafe.akka" %% "akka-kernel" % "2.3.2",
"com.google.guava" % "guava" % "19.0",
"com.google.code.findbugs" % "jsr305" % "3.0.1",
"org.scalatest" %% "scalatest" % "2.2.0" % "test", // Apache v2
"org.mockito" % "mockito-all" % "1.9.5" % "test", // MIT
"com.orange.redis-embedded" % "embedded-redis" % "0.6" % "test",
"org.apache.solr" % "solr-core" % "5.3.0" % "test"
)
mainClass in Compile := Some("com.sillycat.jobsconsumer.ServerBoot")
mappings in Universal ++= {
val base = baseDirectory.value
val confDir = base / "src" / "main" / "resources"
for {
(file, relativePath) <- (confDir.** ("*.conf" || "*.properties") --- confDir) x relativeTo(confDir)
} yield file -> s"conf/$relativePath"
}
After doing that, this command can generate the binary file.
>sbt clean update compile package universal:packageZipTarball
The docker related configuration will be as follow:
Dockerfile
#Run a Simple REST API based on playframework
#Prepre the OS
FROM centos:7
MAINTAINER Carl Luo <luohuazju@gmail.com>
ENV DEBIAN_FRONTEND noninteractive
#Install Java
RUN yum install -y java-1.8.0-openjdk
#Install the Application
RUN mkdir /share/
WORKDIR /share/
ADD target/universal/jobs-consumer-1.0.tgz /share/
#Start the Application
RUN mkdir -p /app/
ADD start.sh /app/
WORKDIR /app
CMD [ "./start.sh" ]
Makefile
IMAGE=sillycat/jobs-consumer
TAG=1.0
NAME=jobs-consumer
REPOSITORY=registry.sillycat.com
push-local:
docker push $(REPOSITORY)/$(IMAGE):$(TAG)
app-build:
sbt clean update compile package universal:packageZipTarball
docker-context:
build: docker-context
sudo docker build -t $(REPOSITORY)/$(IMAGE):$(TAG) .
run-stage:
sudo docker run -v /opt/jobs-consumer/logs:/share/jobs-consumer-1.0/logs -d -e RUNNING_ENV=stage --name $(NAME) $(REPOSITORY)/$(IMAGE):$(TAG)
debug:
sudo docker run -v /opt/jobs-consumer/logs:/share/jobs-consumer-1.0/logs -ti -e RUNNING_ENV=stage --name $(NAME) $(REPOSITORY)/$(IMAGE):$(TAG) /bin/bash
clean:
sudo docker stop ${NAME}
sudo docker rm ${NAME}
logs:
sudo docker logs ${NAME}
publish:
sudo docker push ${IMAGE}
start.sh
#!/bin/sh -ex
APPLICATION_SECRET="nosessionshere"
cd /share/jobs-consumer-1.0
bin/jobs-consumer \
-Dconfig.file=conf/application-${RUNNING_ENV}.conf \
-Dlog4j.configuration=file:conf/log4j-${RUNNING_ENV}.properties
References:
http://sillycat.iteye.com/blog/2123896
https://github.com/muuki88/sbt-native-packager-examples
https://github.com/muuki88/sbt-native-packager-examples/tree/master/assembly-one-jar
发表评论
-
Stop Update Here
2020-04-28 09:00 322I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 484NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 374Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 375Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 345Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 436Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 444Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 381Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 463VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 394Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 488NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 432Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 342Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 255GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 456GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 332GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 318Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 324Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 302Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 315Serverless with NodeJS and Tenc ...
相关推荐
akka-docker-cluster-example, 支持 Docker 支持的akka集群项目示例 akka-docker-cluster-example支持 Docker 支持的akka集群项目示例。 请参见博客文章 。 使用 SBT本机打包程序。:如何运行在SBT中,运行 docker:...
activator-akka-docker, 如何在 Docker 中运行akka群集 Akka & Docker有关详细描述,请阅读这里博客条目。sbt docker:publishLocaldocker run --name seed-1 akka-docker:2.3.4 --seeddoc
docker run --name seed-1 akka-docker:2.3.4 --seed docker run --name seed-2 akka-docker:2.3.4 --seed < ip> :2551 docker run --name node-1 akka-docker:2.3.4 < ip> :2551 < ip> :2551 docker run --name ...
总结来说,这个"机械手控制系统"项目展示了如何综合运用Java、Spring Boot、Docker和Akka等技术来构建一个复杂的、分布式的控制系统。通过Docker化的Spring Boot应用与Akka集群的结合,实现了系统的高可用性和可扩展...
Deploying an application using Docker and Kubernetes
配置此 docker 映像包含以下软件堆栈: 操作系统:Debian 杰西。 Java:Oracle JDK 1.7.0 Scala:2.11.4 Sbt ,建立在 + 框架之上。依赖关系历史0.1 - 初始版本。安装 $ docker pull williamyeh/spray-httpserver...
If you are an application developer who wants to learn Docker in order to utilize its features for application deployment, then this book is for you. No prior knowledge of Docker is required. What ...
akka-cluster-example-inloop 简单的 akka 集群示例。 跑步: 安装 cassandra 并启动它。 sbt clean 编译 xitrum-package cd 目标/xitrum/bin ./start.sh 种子1 ./start.sh 种子2 ./start.sh stat1 ./start....
主要介绍了用Docker快速构建LEMP环境的方法示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
废话不多说,直接上干货 ...yum remove docker docker-common docker-selinux docker-engine 3、安装docker yum -y install docker 4、启动docker和查看docker的状态 systemctl start docker——
Containerized-Docker-Application-Lifecycle-with-Microsoft-Platform-and-Tools
3)本文涵盖内容有:daemon.json、docker.service、docker-20.10.7.tgz、docker-compose-linux-x86_64 4)本资源对应的配套博客内容地址为:https://blog.csdn.net/qq_23845083/article/details/141352156,有需要...
Docker 离线安装 MySQL 5.7 使用说明 本文将指导你如何使用离线的 Docker 镜像包 (docker-mysql-5.7.tar.zip) 来在 Linux 系统中安装并运行 MySQL 5.7 容器。 前提条件 • 已安装 Docker 环境。 • MySQL 5.7 ...
安装docker 获取root 权限 su root 拷贝所有文件到 /opt/docker/ (如果没有 docker目录执行 mkdir -p /opt/docker) yum localinstall -y /opt/docker/*.rpm 安装docker-compose cd /opt/docker/ tar ...
Docker在IT行业中是一款非常重要的容器化平台,它允许开发者将应用程序及其依赖打包到一个可移植的容器中,便于在各种环境中快速部署和运行。在Windows操作系统上安装Docker,可以借助Docker Desktop或者Docker ...
Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify ExecStart=...
离线环境下,在centos7.6系统上安装docker-ce-19.03,nvidia-docker2.4版本,其中docker-ce-19.03在docker-local.tar压缩文件里面,nvidia-docker2在nvidia-docker2.zip文件中。 具体安装流程如下: 1.安装docker ...
在IT行业中,Docker和Docker Compose是两个非常重要的工具,它们被广泛应用于容器化应用程序的部署和管理。Ubuntu是流行的Linux操作系统,它为Docker提供了良好的支持。本资源包提供的是Ubuntu 20.10.12版本上的...
Docker-Compose项目是Docker官方的开源项目,负责实现对Docker容器集群的快速编排。 Docker-Compose将所管理的容器分为三层,分别是工程(project),服务(service)以及容器(container)。Docker-Compose运行目录...
在Ubuntu系统上离线安装Docker和NVIDIA-docker是一项技术性较强的任务,尤其是在没有网络连接的情况下。这里我们将详细介绍如何通过提供的离线资源包完成这一过程。 首先,我们需要理解Docker和NVIDIA-docker的基本...