将java程序成为linux的系统服务
2023-09-14 08:56:51 时间
在分布式环境开发中经常会使用socket,或者使用rmi来对外提供服务,常用的办法是将写一个java代码,然后部署到服务器上,但是问题来了。如何将这个服务成为一个可靠的系统服务,不会应为风吹草动就挂了,那就不好了。
所以想到使用apache commons 下面的daemon框架来充当守护进程。首
-cp / -classpath directories and zip/jar files set search path for service classes and resouces -home directory set the path of your JDK or JRE installation (or set the JAVA_HOME environment variable) -version show the current Java environment version (to check correctness of -home and -jvm. Implies -nodetach) -showversion show the current Java environment version (to check correctness of -home and -jvm) and continue execution. -nodetach dont detach from parent process and become a daemon -debug
/home/baisui/commons-daemon-1.0.10-native-src/unix/jsvc -pidfile ./pidfile.pid -outfile ./logs/trigger_server_out.log -errfile ./logs/trigger_server_err.log -cp $CLASSPATH com.taobao.terminator.trigger.LaunchServer
stop(){ /home/baisui/commons-daemon-1.0.10-native-src/unix/jsvc -stop -pidfile ./pidfile.pid -cp $CLASSPATH com.taobao.terminator.trigger.LaunchServer echo "trigger_server stopped"
从 Linux 内核线程反观 Java Go 的线程模型 原文参考我的个人公众号文章(欢迎关注!):[点此链接进入](https://mp.weixin.qq.com/s?__biz=MzkxNDMyNjk0Mw== mid=2247484374 idx=1 sn=5e5c8ef7adc0841019cb3302ed5003db chksm=c1715726f606de301494abf87fbdc40303bdb9ac8393333b0778e23
在分布式环境开发中经常会使用socket,或者使用rmi来对外提供服务,常用的办法是将写一个java代码,然后部署到服务器上,但是问题来了。如何将这个服务成为一个可靠的系统服务,不会应为风吹草动就挂了,那就不好了。
所以想到使用apache commons 下面的daemon框架来充当守护进程。首先需要在系统中安装jsvc工具具体操作方法这里不作详细说明,请查看 http://commons.apache.org/daemon/jsvc.html。
最后jsvc安装成功之后需要有执行 jsvc -help 会显示以下内容:
-cp / -classpath directories and zip/jar files set search path for service classes and resouces -home directory set the path of your JDK or JRE installation (or set the JAVA_HOME environment variable) -version show the current Java environment version (to check correctness of -home and -jvm. Implies -nodetach) -showversion show the current Java environment version (to check correctness of -home and -jvm) and continue execution. -nodetach dont detach from parent process and become a daemon -debug
/home/baisui/commons-daemon-1.0.10-native-src/unix/jsvc -pidfile ./pidfile.pid -outfile ./logs/trigger_server_out.log -errfile ./logs/trigger_server_err.log -cp $CLASSPATH com.taobao.terminator.trigger.LaunchServer
stop(){ /home/baisui/commons-daemon-1.0.10-native-src/unix/jsvc -stop -pidfile ./pidfile.pid -cp $CLASSPATH com.taobao.terminator.trigger.LaunchServer echo "trigger_server stopped"
从 Linux 内核线程反观 Java Go 的线程模型 原文参考我的个人公众号文章(欢迎关注!):[点此链接进入](https://mp.weixin.qq.com/s?__biz=MzkxNDMyNjk0Mw== mid=2247484374 idx=1 sn=5e5c8ef7adc0841019cb3302ed5003db chksm=c1715726f606de301494abf87fbdc40303bdb9ac8393333b0778e23
相关文章
- Linux:为计算机带来无限可能性(linux系统干什么的)
- Linux管道线:传输数据的精髓(linux管道线)
- 学习Linux:简易命令指引(简单的linux命令)
- Linux系统下实现网卡休眠的方法(网卡休眠linux)
- 在虚拟机中实现Linux网络连接(虚拟机中linux联网)
- Linux下获取系统时间的方法(获取系统时间linux)
- Linux驱动的智能电视系统新时代。(linux电视系统)
- Linux下快捷修改系统密码的方法(linux修改系统密码)
- 利用Linux中的管道符实现更强大的运行效果(linux中管道符)
- Linux系统如何安全删除DB2(linux删除db2)
- 系统的实现实现Linux的极致体积:Mini系统的运用(linux中mini)
- Linux查看根目录:简易步骤指南(linux查看根目录)
- Linux的新分支:开放无限可能(linux的分支)
- 文件Linux下合并文本文件的实现(linux合并文本)
- Linux开机启动顺序概述(linux开机启动顺序)
- Linux系统为何默认使用root账户?(linux默认root)
- 小红帽Linux中文:开源技术趋势下诞生的全面IT办公利器(小红帽linux中文)
- 如何在Linux系统中查看默认字符集(linux查看默认字符集)
- Linux网络服务的启动方法(linux 启动网络服务)
- 如何在Linux系统中查看文件共享?(linux查看文件共享)
- 系统的威胁Linux系统面临被勒索病毒侵袭的威胁(勒索病毒对linux)