[英]Jenkins is not running when the jenkins.war is not running
我正在尝试为我正在从事的 selenium/maven 项目自动安排 Jenkins 作业。 一切运行正常且自动调度仅在 .jar 文件运行时有效(使用命令: java -jar jenkins.war --httpPort=8089
) 但是,一旦我退出命令提示符和 Jenkins 服务器,它就根本不会运行。 我假设它应该运行,无论是否连接以及计算机正在登录或注销。
在我看来,当 jenkins.war 文件未启动和运行时,Jenkins 自动调度不起作用。
我在这里错过了什么吗?
如果未执行.war
文件,则整个jenkins
进程不会运行。 问题是你如何运行 Jenkins。
有大量文档如何运行它。 但是,我最终通过system.d
服务文件在启用systemd
的操作系统(linux)上运行: /usr/lib/systemd/system/jenkins.service
:
[Unit]
Description=Jenkins
Documentation=https://wiki.jenkins.io/display/JENKINS/Use+Jenkins
After=network.target
Requires=network.target
[Service]
Type=simple
EnvironmentFile=/etc/default/jenkins
ExecStart=/home/jenkins/jdk/jdk1.8.0_121/bin/java -Xmx2048m -Xms1024m -DJENKINS_HOME=/home/jenkins -jar /home/jenkins/jenkins.war --javaHome=/home/jenkins/jdk/jdk1.8.0_121 --httpPort=8080 --webroot=/var/cache/jenkins/war --ajp13Port=-1 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
# Restart=always
# RestartSec=120
User=jenkins
[Install]
WantedBy=multi-user.target
与: /etc/default/jenkins
:
# Managed manually
JENKINS_HOME="/home/jenkins"
#JENKINS_LOGFILE="/home/jenkins/jenkins.log"
# TODO: manage JAVA_HOME through java-alternatives
JAVA_HOME="/home/jenkins/jdk/jdk1.8.0_121"
JAVA_OPTIONS="-Xmx2048m -Xms1024m"
# Web Configuration
HTTP_WEB_ROOT="/var/cache/jenkins/war"
HTTP_PORT="8080"
HTTP_LISTEN_ADDRESS="0.0.0.0"
# Jenkins Configurations
# more: https://wiki.jenkins.io/display/JENKINS/Starting+and+Accessing+Jenkins
JENKINS_ARGS="--ajp13Port=-1 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20"
$ systemctl status jenkins
● jenkins.service - Jenkins
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; linked; vendor preset: disabled)
Active: active (running) since Wed 2021-03-31 10:08:36 EDT; 1 weeks 1 days ago
Docs: https://wiki.jenkins.io/display/JENKINS/Use+Jenkins
Main PID: 27219 (java)
Tasks: 70 (limit: 512)
CGroup: /system.slice/jenkins.service
└─27219 /home/jenkins/jdk/jdk1.8.0_121/bin/java -Xmx2048m -Xms1024m
并通过Apache HTTP服务器发布,通过ProxyPath:
$ systemctl status apache
● apache2.service - The Apache Webserver
Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2021-02-02 12:34:05 EST; 2 months 4 days ago
Process: 30426 ExecReload=/usr/sbin/start_apache2 -DSYSTEMD -DFOREGROUND -k graceful (code=exited, status=0/SUCCESS)
Main PID: 18524 (httpd-prefork)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Tasks: 11
CGroup: /system.slice/apache2.service
使用 Apache HTTP 虚拟主机配置:
<IfDefine SSL>
<IfDefine !NOSSL>
##
## SSL Virtual Host Context
##
<VirtualHost _default_:443>
ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
# ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Proxy http://localhost:8080/*>
Require all granted
</Proxy>
# ProxyPassMatch ^/(?\!.well-known) http://localhost:8080 nocanon
ErrorLog /var/log/apache2/error_log
TransferLog /var/log/apache2/access_log
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# You can use per vhost certificates if SNI is supported.
SSLCertificateFile /etc/apache2/ssl.crt/<your-server>.com.crt
SSLCertificateKeyFile /etc/apache2/ssl.key/<your-server>.com.key
CustomLog /var/log/apache2/ssl_request_log ssl_combined
</VirtualHost>
</IfDefine>
</IfDefine>
相同的配置设置,但通过 NGINX: Jenkins 反向代理配置 nginx
通过这种方式,您可以管理您的 jenkins 服务器(启动/停止)并管理 TLS (SSL) 通信:
systemctl status jenkins nginx
If you run Jenkins through Docker, you don't need another WebServer (eg Apache/NGINX) in front of Jenkins as publicly, you're not going to expose the Jenkins Docker container, but you probably have a Kubernetes/(A)LB在前。 不建议公开 Jenkins。
WebServer 使您可以灵活地在 Jenkins 前面使用缓存或 CDN,尤其是在您使用发布工件功能时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.