How to deploy a Java Linux Daemon with Java Servcie Wrapper
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了How to deploy a Java Linux Daemon with Java Servcie Wrapper,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2013字,纯文字阅读大概需要3分钟。
内容图文
Java Service Wrapper (http://wrapper.tanukisoftware.com/doc/english/integrate.html) is a tool that provides a set of binaries and scripts for different architectures and operating systems that allow Java developers to run a Java application as a service daemon.
For this post I used a 64-bit CentOS PC as a server.
The source code of my test program is :
import java.text.SimpleDateFormat; import java.util.Date; /** * @author XingNing OU */ public class SegmentServiceMain { public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); while (true) { System.out.println(sdf.format(new Date())); try { Thread.sleep(2000L); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
1. Preparing the environment:
# mkdir -p /data/app/segment/bin # mkdir -p /data/app/segment/conf # mkdir -p /data/app/segment/logs # cp -r segment.jar /data/app/segment/bin/
2. Download and install Java Service Wrapper for Linux:
# wget http://wrapper.tanukisoftware.com/download/3.5.25/wrapper-linux-x86-64-3.5.25.tar.gz
3. Extract the package and copy the files needed:
# tar -zxvf wrapper-linux-x86-64-3.5.25.tar.gz # cd wrapper-linux-x86-64-3.5.25 # cp bin/wrapper /data/app/segment/bin/ # cp src/bin/sh.script.in /data/app/segment/bin/ # cp lib/* /data/app/segment/bin/ # cp conf/wrapper.conf /data/app/segment/conf/
4. Rename the servcie script and set correct permissions:
# cd /data/app/segment/bin/ # mv sch.script.in segment-service # chmod +x segment-servcie
5. Changeing some directive from the config file (wrapper.conf)
6. Edit inti script (segment-service)
7. Run the application at boot time:
# ln -s /data/app/segment/bin/segment-service /etc/init.d/segment-service # chkconfig --levels 235 segment-service on
Reference:
http://opentodo.net/2013/03/deploying-java-unix-daemon-with-java-service-wrapper/
原文:http://www.cnblogs.com/ouxingning/p/java_daemon_servcie.html
内容总结
以上是互联网集市为您收集整理的How to deploy a Java Linux Daemon with Java Servcie Wrapper全部内容,希望文章能够帮你解决How to deploy a Java Linux Daemon with Java Servcie Wrapper所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。