在 Linux 环境中,TongWeb 默认一般通过 bin 目录下的脚本进行启动和停止:
启动:
./startd.sh停止:
./stopserver.sh这种方式每次都需要进入 TongWeb 安装目录操作,如果服务器重启,还需要人工启动。
可以将 TongWeb 配置成 systemd 服务,之后直接使用 systemctl 管理。
例如:
systemctl start tongweb systemctl stop tongweb systemctl restart tongweb systemctl status tongweb配置 TongWeb 服务
创建服务文件:
vim /etc/systemd/system/tongweb.service写入以下内容:
[Unit] Description=TongWeb Middleware After=network.target syslog.target [Service] Type=forking WorkingDirectory=/home/chenyanliang/dft/TongWeb8.0.9.12/bin Environment=JAVA_HOME=/usr/local/java/jdk1.8 User=chenyanliang Group=chenyanliang ExecStart=/home/chenyanliang/dft/TongWeb8.0.9.12/bin/startd.sh ExecStop=/home/chenyanliang/dft/TongWeb8.0.9.12/bin/stopserver.sh TimeoutStartSec=120 TimeoutStopSec=60 PrivateTmp=false Restart=on-failure RestartSec=10 StandardOutput=journal+console StandardError=journal+console [Install] WantedBy=multi-user.target注意修改以下配置:
TongWeb 安装路径:
/home/chenyanliang/dft/TongWeb8.0.9.12需要替换成实际 TongWeb 安装目录。
例如:
WorkingDirectory=/你的TongWeb目录/bin ExecStart=/你的TongWeb目录/bin/startd.sh ExecStop=/你的TongWeb目录/bin/stopserver.sh同时:
User=chenyanliang Group=chenyanliang修改为实际运行 TongWeb 的用户。
加载配置
创建完成后执行:
systemctl daemon-reload让 systemd 重新读取服务配置。
TongWeb 启停管理
启动 TongWeb:
systemctl start tongweb停止 TongWeb:
systemctl stop tongweb重启 TongWeb:
systemctl restart tongweb查看运行状态:
systemctl status tongweb设置开机自动启动
如果希望服务器重启后自动启动 TongWeb:
systemctl enable tongweb查看是否设置成功:
systemctl is-enabled tongweb配置完成后,TongWeb 的日常管理就可以直接通过 systemctl 完成,不需要再进入 TongWeb 的 bin 目录手动执行启动脚本。这样也方便后续服务器重启、故障自动拉起等运维操作。