在 RedHat 中自动启动 Web 服务

发布于 2024-11-08 15:04:15 字数 2100 浏览 4 评论 0原文

我需要在 RedHat 服务器上自动启动 Web 服务。 Web 服务可以正常工作,并且可以通过 NetBeans 手动加载。

尝试使用户只需要执行单个命令行或类似的操作即可运行它。

从启动并运行 GlassFish 服务器开始(使用 http://blogs.oracle.com/foo/entry /run_glassfish_v3_as_a 主要是,还有一些来自其他来源的输入)

这导致我做了以下事情;

-添加了新用户

groupadd glassfish

useradd -s /bin/bash -d /home/glassfish -m -g glassfish glassfish 

-以所述用户身份登录

sudo -i -u glassfish 

-安装 glassfish

cd ~

unzip glassfish-v3.zip

rm glassfish-v3.zip

-离开 shell

-将脚本复制到 /etc/init.d 并将其配置为可执行文件

cp <script file as shown below> /etc/init.d/glassfish 

chmod +x /etc/rc.d/init.d/glassfish

* 脚本*


#!/bin/sh
# Platform Services for GlassFish
#
GF_USER=glassfish
GF_HOME=/home/$GF_USER/glassfishv3/glassfish
ASADMIN=$GF_HOME/bin/asadmin
SU="su --login  $GF_USER --command  "

case "$1" in start)
    $SU "$ASADMIN start-domain > /dev/null 2>&1 &";;stop)
    $SU "$ASADMIN stop-domain > /dev/null 2>&1 &";;restart)
    $SU "$ASADMIN restart-domain > /dev/null 2>&1 &";;\*)
    echo "usage: $0 (start|stop|restart|help)"esac

可以启动/停止/重新启动; sudo /etc/init.d/glassfish start|stop|restart

我相信问题是 Glassfish 正在运行,但我的小 Java Web 服务没有运行。我对 java web 服务没有运行并不感到惊讶,因为我从未将其包含在上面,但是如何设置它以便我的 web 服务运行?


今天早上我进来后意识到我需要部署java客户端。我按照

http://download.oracle.com/docs/cd/E19798-01/821-1757/geyvr/index.html" rel="nofollow">http:// /download.oracle.com/docs/cd/E19798-01/821-1757/geyvr/index.html

用于自动部署应用程序。

但现在使用这种方法,我的 Windows Web 客户端无法与我的 RedHat 主机通信,但手动启动时它们非常高兴。

我能想到的唯一区别是,手动启动服务时 Redhat 机器上的用户是“root”(这对于 Web 应用程序来说有点危险)。但是当自动启动客户端时,它会以用户身份运行...当然这可能完全是为了转移注意力...

大家有什么想法吗?

I need to launch a web service automatically on a RedHat server. The web service works and can be loaded manually through NetBeans.

Trying to make it so that the user only needs to perform a single command line or similar to get it running.

Started with getting GlassFish server up and running (used http://blogs.oracle.com/foo/entry/run_glassfish_v3_as_a mainly, with some input from other sources)

This led to me doing the following;

-Added new user

groupadd glassfish

useradd -s /bin/bash -d /home/glassfish -m -g glassfish glassfish 

-Logged in as said user

sudo -i -u glassfish 

-Installed glassfish

cd ~

unzip glassfish-v3.zip

rm glassfish-v3.zip

-Left the shell

-Copied in script to /etc/init.d and configured it as an executable

cp <script file as shown below> /etc/init.d/glassfish 

chmod +x /etc/rc.d/init.d/glassfish

* THE SCRIPT *


#!/bin/sh
# Platform Services for GlassFish
#
GF_USER=glassfish
GF_HOME=/home/$GF_USER/glassfishv3/glassfish
ASADMIN=$GF_HOME/bin/asadmin
SU="su --login  $GF_USER --command  "

case "$1" in start)
    $SU "$ASADMIN start-domain > /dev/null 2>&1 &";;stop)
    $SU "$ASADMIN stop-domain > /dev/null 2>&1 &";;restart)
    $SU "$ASADMIN restart-domain > /dev/null 2>&1 &";;\*)
    echo "usage: $0 (start|stop|restart|help)"esac

Can start/stop/restart with;
sudo /etc/init.d/glassfish start|stop|restart

The problem is, I believe, that Glassfish is running but my little Java web service isn’t. I’m not surprised that the java web service isn’t running as I never included it in the above, but how do I set it up so that my web service is run?


I came in this morning and realised that I needed to deploy the java client. I did this by following the instructions from

http://download.oracle.com/docs/cd/E19798-01/821-1757/geyvr/index.html

For deploying applications automatically.

But now using this method my windows web-client can't talk to my RedHat host, but they are perfectly happy when started manually.

The only difference I can think of is that the user on the Redhat machine when starting the services manually is "root" (which is a bit dangerous for a web application). But when starting the client automatically, it runs as a user... Of course this could be a complete red herring....

Any ideas guys?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

究竟谁懂我的在乎 2024-11-15 15:04:15

假设您的 Web 服务有一个 war 文件,那么部署应该就像将 war 文件复制到 glassfish 的 webapps 目录中一样简单。

Assuming that you have a war file for your web service, then deploying should be as simple as copying the war file in the webapps directory of glassfish.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文