-
-
Save karnauskas/aca138bb8338689a178e to your computer and use it in GitHub Desktop.
[Unit] | |
Description=Jenkins | |
After=network.target | |
Requires=network.target | |
[Service] | |
Type=simple | |
EnvironmentFile=/etc/sysconfig/jenkins | |
ExecStart=/usr/bin/java ${JENKINS_JAVA_OPTIONS} -jar /usr/lib/jenkins/jenkins.war --httpPort=${JENKINS_PORT} --httpListenAddress=${JENKINS_LISTEN_ADDRESS} ${JENKINS_ARGS} | |
Restart=always | |
User=jenkins | |
RestartSec=20 | |
[Install] | |
WantedBy=multi-user.target |
Thank you for the reference !! ... just in case for Jenkins LTS 2.319.2 you can use something like:
/etc/jenkins/jenkins.conf
JENKINS_WAR=/opt/jenkins/jenkins.war
JENKINS_HOME=/opt/jenkins/home
JAVA_ARGS="-Djava.awt.headless=true \
-Djava.net.preferIPv4Stack=true \
-XX:+AlwaysPreTouch \
-XX:+UseG1GC \
-Xms1024m \
-Xmx1024m \
-Xss16m \
-Xlog:gc*=debug:file=gclog.log:utctime,level,tags:filecount=9,filesize=1M"
JENKINS_ARGS="--httpPort=8080 \
--logfile=/var/log/jenkins/jenkins.log \
--useJmx"
/lib/systemd/system/jenkins.service
[Unit]
Description=Jenkins
After=network.target
[Service]
Type=simple
User=jenkins
Group=jenkins
EnvironmentFile=/etc/jenkins/jenkins.conf
ExecStart=/usr/bin/java $JAVA_ARGS -jar $JENKINS_WAR $JENKINS_ARGS
WorkingDirectory=/opt/jenkins/home
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Ensure you have the jenkins user created with the Jenkins home and logs directory permissions with the Jenkins war downloaded at /opt/jenkins/jenkins.war and just run the command systemctl start jenkins
Tested on Debian 11 Bullseye arm64 and OpenJDK 11 in and AWS m6g.large
Based on:
https://www.jenkins.io/doc/book/managing/system-properties/
https://www.jenkins.io/doc/book/installing/initial-settings/
https://github.com/jenkinsci/winstone#command-line-options
Interesting to see that small piece of config still makes some traction 7 years later.
Interesting to see that small piece of config still makes some traction 7 years later.
Because in all these years the Jenkins project still hasn't shipped systemd(1)
-based packages. But that is about to change in jenkinsci/packaging#266.
Buenísimo !! 👍😎
Me ha servido mucho, gracias
And you think I know what was there 5 years ago? Something like this. You're welcome.