java Wildfly 作为系统服务
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42907443/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
wildfly as systemd service
提问by Mehrdad Islamkhah
I wanna make wildfly-domain as a systemd service in centos7
in works by root user but when i start it as wilfly
user after a while it shows error:
我想让wildfly-domain作为root用户在centos7中的systemd服务,但是当我wilfly
在一段时间后以用户身份启动它时,它显示错误:
java.lang.OutOfMemoryError: unable to create new native threadESC
and stop . even stop service doesn't work .
java.lang.OutOfMemoryError: 无法创建新的本地线程ESC
并停止。即使停止服务也不起作用。
I tried to change heap-memo and ... but the user is a problem! How can I solve this?
我试图改变 heap-memo 和...但用户是一个问题!我该如何解决这个问题?
service file is ib wildfly8/bin/init.d/wildfly-init-redhat.sh I tried "ulimit -n " at the top of service script but nothing changed! I have 256Gb Ram and 64core CPU but ....
服务文件是 ib wildfly8/bin/init.d/wildfly-init-redhat.sh 我在服务脚本的顶部尝试了“ulimit -n”,但没有任何改变!我有 256Gb 内存和 64 核 CPU 但是....
回答by Oleg Gritsak
Right place for unit is:
单元的正确位置是:
/etc/systemd/system/wildfly.service
This minimal is ok
这个最小是可以的
[Unit]
Description=WildFly application server
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=web
Group=web
ExecStart=/opt/wildfly-10.1.0.Final/bin/domain.sh
Restart=always
RestartSec=20
[Install]
WantedBy=multi-user.target
You should edit only ExecStart field to match your path.
您应该只编辑 ExecStart 字段以匹配您的路径。
Create user webwith
创建用户的网络使用
useradd web
Also exec by root:
也可以通过 root 执行:
chown -R web:web /opt/wildfly-10.1.0.Final/
When
什么时候
systemctl start wildfly
systemctl enable wildfly
If you get OOMs, inspect your limits
如果您遇到 OOM,请检查您的限制
[Service]section of systemd unit, like
systemd 单元的[Service]部分,例如
LimitFSIZE=infinity
LimitCPU=infinity
LimitAS=infinity
LimitNOFILE=64000
LimitNPROC=64000
or /etc/security/limits.d/ /etc/security/limits.conf
或 /etc/security/limits.d/ /etc/security/limits.conf