惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - lzhou666

使用Spring Sleuth和Zipkin跟踪微服务 HttpClient4.5 SSL访问工具类 多线程处理中Future的妙用 hystrix-turbine 监控的使用 spring boot/cloud 应用监控 spring boot 自动部署方案 使用spring boot和thrift、zookeeper建立微服务 计数器 使用docker发布spring cloud应用 综合使用spring cloud技术实现微服务应用 Spring cloud实现服务注册及发现 使用spring cloud实现分布式配置管理 spring cloud教程之使用spring boot创建一个应用 7天学会spring cloud教程 微服务开发的12项要素 一句话概括下spring框架及spring cloud框架主要组件 翻译-服务注册与发现 翻译-微服务API Gateway 微服务分布式事务的一些思考
spring cloud开发、部署注意
lzhou666 · 2017-07-27 · via 博客园 - lzhou666

一、开发时,配置服务的配置使用本地路径,不使用svn和git,因为后者每个开发人员都会修改配置,导致别人也拿到其他人修改的配置,本地配置示例如下:

spring:
  application:
    name: simple-config-server
  cloud:
    config:
      server:       
        default-label: trunk  
        native:
          searchLocations: file:///D:\works\smart\simple-config-repo                  
  profiles:
    active: native

二、对于生产环境部署到阿里云的,使用不了docker,因为docker文件通常有几百兆,部署时上传很慢。不但不能使用docker,打包时也没有必要包含所有的包,如果去掉依赖包,编译完后每个jar只有几百k,这样部署起来就方便多了。可以如下设置pom编译选项:

<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<configuration>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
							<mainClass>ebtins.smart.proxy.SmartProxyApplication</mainClass>
							<classpathPrefix>lib/</classpathPrefix>
						</manifest>
					</archive>
				</configuration>
			</plugin>
		</plugins>
		<defaultGoal>compile</defaultGoal>
	</build>
	

这样你生产环境的服务目录将如下,simple-service.jar只有几百K。

simple-service.jar simple-service.sh lib logs

三、使用脚本启动和关闭服务,centos下的脚本启动和关闭可以如下:

start(){  
 now=`date "+%Y%m%d%H%M%S"`  
 exec 
 java -Xms64m -Xmx256m -jar ./simple-service-0.0.1.jar --server.port=7085 --config.name=pro > logs/simple-service.log & 
}  
#停止方法  
stop(){  
 ps aux|grep simple-service|grep 7085|grep -v grep|awk '{print $2}'|while read pid  
 do  
    kill -9 $pid 
 done 
}  
  
case "$1" in  
start)  
start  
;;  
stop)  
stop  
;;    
restart)  
stop  
start  
;;  
*)  
printf 'Usage: %s {start|stop|restart}\n' "$testg"  
exit 1  
;;  
esac


启动方式:sh simple-service.jar start
当然可以在脚本里启动本服务器所有服务,也可以使用自动部署机制,自动部署自动启动。
这是生产和开发环境的一点小小经验。