java - 当 jenkins.war 未运行时,Jenkins 未运行
问题描述
我正在尝试为我正在从事的 selenium/maven 项目自动安排 Jenkins 工作。一切运行正常,自动调度仅在 .jar 文件运行时才有效(使用命令:)java -jar jenkins.war --httpPort=8089
。但是一旦我退出命令提示符和 Jenkins 服务器,它就根本不会运行。我假设它应该运行,无论是否连接以及计算机正在登录或注销。
在我看来,当 jenkins.war 文件未启动并运行时,Jenkins Autoscheduling 不起作用。
我在这里错过了什么吗?
解决方案
如果文件没有被执行,整个jenkins
过程就不会运行。.war
问题是你如何运行 Jenkins。
有大量文档如何运行它。但是,我最终通过拥有一个服务文件在systemd
启用的操作系统(linux)上运行::system.d
/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 Server 发布它,通过 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 reverse-proxy configuration nginx
通过这种方式,您可以管理您的 jenkins 服务器(启动/停止)并管理 TLS (SSL) 通信:
systemctl status jenkins nginx
如果你通过 Docker 运行 Jenkins,你不需要在 Jenkins 前面公开另一个 WebServer(例如 Apache/NGINX),你不会公开 Jenkins Docker 容器,但你可能有一个 Kubernetes/(A)LB在前。不建议公开曝光 Jenkins。
WebServer 让您可以灵活地在 Jenkins 前使用缓存或 CDN,尤其是在您使用Publish artifacts功能的情况下。
推荐阅读
- html - 在 GitHub markdown.md 中显示 LAtex 公式
- reactjs - Framer Motion - 使 div 在页面上随机移动
- python - 如何利用 Catboost 中的 MAP 评估指标来计算平均精度?
- c# - 如何使用 Nest 客户端将日期范围应用于聚合查询
- javascript - 如何在 Node.js (Javascript) 中提取 mp3/mp4 的封面艺术/缩略图?
- javascript - 不和谐.js。无法为斜杠命令添加权限
- css - 在 react 中使用 css 模块不会影响任何事情
- reactjs - 如何将 2021-07-14T00:00:00.000Z 转换为 YYYY-MM-DD 格式的标准日期
- python - 如何在 django 的 ajax url 中传递 kwargs?未找到带有参数 '('',)' 的 '' 的反向操作。尝试了 1 种模式:['partners/analytics/(?P
[0-9]+)/$'] - email - 第三方如何从 gmail 发送批量电子邮件?