linux下实现glassfish自动启动
1. 首先在 创建文件/etc/init.d/glassfish3, 文件内容如下. 注意修改下列内容的红色部分(不好意思,全部用英文写的)
Sh代码
#! /bin/sh
# This shell script takes care of starting and stopping
# the glassfish DAS and glassfish instance.
#
# chkconfig: - 64 36
# description: glassfish management
# processname: glassfish
#if you face any problems add the path to your Java
#this way (see Jeffrey's comments below)
export AS_JAVA=<span style="color: #ff0000;">/usr/java/jdk1.6.0_17</span>
#export CLASSPATH=.;$AS_JAVA/lib/dt.jar;$AS_JAVA/lib/tools.jar
GLASSFISHPATH=<span style="color: #ff0000;">/opt/glassfish3/bin</span>
export PASSWD=<span style="color: #ff0000;">/opt/glassfish3/bin/.passwd</span>
case "$1" in
start)
echo "starting glassfish from $GLASSFISHPATH"
su - root $GLASSFISHPATH/asadmin start-domain
#start your instance at start time, if you do not have instance, comment these two lines
<span style="color: #ff0000;">echo "starting instance st_server"
$GLASSFISHPATH/asadmin --user admin --passwordfile $PASSWD start-instance st_server
</span>
#we need to use this later when we enable https
#sudo -u glassfish $GLASSFISHPATH/asadmin --secure start-domain domain1
;;
status)
$0 start
;;
restart)
$0 stop
$0 start
;;
stop)
<span style="color: #ff0000;">echo "stopping instance st_server"
$GLASSFISHPATH/asadmin --user admin --passwordfile $PASSWD stop-instance st_server
</span>
echo "stopping glassfish from $GLASSFISHPATH"
su - root $GLASSFISHPATH/asadmin stop-domain
#we need to use this later when we enable https
#sudo -u root $GLASSFISHPATH/asadmin --secure stop-domain domain1
;;
*)
echo $"usage: $0 {start|stop|restart|status}"
exit 3
;;
esac
设置成可执行文件,
Java代码
$ sudo chmod +x /etc/init.d/glassfish3
其中的password文件如下
.passwd代码
AS_ADMIN_PASSWORD=administration-password
请将 administration-password修改成你自己的密码
2. 查看刚刚添加的服务
Java代码
chkconfig --list glassfish3
你应该看到
Java代码
相关新闻>>
- 发表评论
-
- 最新评论 更多>>