Skip to content

Instantly share code, notes, and snippets.

@silvae86
Last active November 13, 2017 17:44
Show Gist options
  • Save silvae86/5e34896bb83a6804d72a8bcf109f09f5 to your computer and use it in GitHub Desktop.
Save silvae86/5e34896bb83a6804d72a8bcf109f09f5 to your computer and use it in GitHub Desktop.
Jenkins Configs
#Jenkins settings
# Allow graphs etc. to work even when an X server is present
JAVA_ARGS="-Djava.awt.headless=true -server -XX:+AlwaysPreTouch -Xloggc:$JENKINS_HOME/gc-%t.log -XX:NumberOfGCLogFiles=5 -XX:+UseGCLogFileRotation -XX:GCLogFileSize=20m -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintHeapAtGC -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintReferenceGC -XX:+PrintAdaptiveSizePolicy -XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent -XX:+ParallelRefProcEnabled -XX:+UseStringDeduplication -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:+UnlockDiagnosticVMOptions -XX:G1SummarizeRSetStatsPeriod=1 -Xmx768m -Xmx768m"
[Unit]
Description=Jenkins watchdog daemon, because it works so well that it needs to be restarted if it stops responding, useless jenkins service is unable to do it...
[Service]
Type=simple
Restart=always
RestartSec=60s
TimeoutStartSec=infinity
User=root
Group=sudo
RuntimeMaxSec=infinity
KillMode=control-group
ExecStart=/scripts/reboot_jenkins_if_needed.sh
#IDFile=/dendro/service_pids/dendroBuildServer
[Install]
WantedBy=multi-user.target
#!/bin/bash
ADDRESS="127.0.0.1"
PORT=8111
COMMAND="sudo service jenkins restart"
#while true
#do
# if [ "$PORT" != "" ];
# then
# ADDRESS="$ADDRESS:$PORT"
# fi
nc -zv "$ADDRESS" "$PORT"
if [ "$?" != "0" ];
then
echo "Restarting jenkins because it is dead" && `$COMMAND`
else
echo "Jenkins is running, no need to restart it"
fi
# curl -sSf "$ADDRESS" --connect-timeout 10 --max-time 60 > /dev/null && echo "Jenkins is running, no need to restart it"&& echo "Jenkins is running, no need to restart it" || echo "Restarting jenkins because it is dead" && `$COMMAND`
# sleep 60
#done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment