jenkins-bin.init2 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/sbin/openrc-run
  2. depend() {
  3. need net
  4. use dns logger mysql postgresql
  5. }
  6. checkconfig() {
  7. if [ ! -n "$JENKINS_HOME" ] ; then
  8. eerror "JENKINS_HOME not configured"
  9. return 1
  10. fi
  11. if [ ! -d "$JENKINS_HOME" ] ; then
  12. checkpath -q -d -o jenkins:jenkins -m 0755 "$JENKINS_HOME" || return 1
  13. fi
  14. return 0
  15. }
  16. start() {
  17. checkconfig || return 1
  18. JAVA_HOME=`java-config --jre-home`
  19. COMMAND=$JAVA_HOME/bin/java
  20. JAVA_PARAMS="$JENKINS_JAVA_OPTIONS -DJENKINS_HOME=$JENKINS_HOME -jar $JENKINS_WAR"
  21. # Don't use --daemon here, because in this case stop will not work
  22. PARAMS="--logfile=/var/log/jenkins/jenkins.log"
  23. [ -n "$JENKINS_PORT" ] && PARAMS="$PARAMS --httpPort=$JENKINS_PORT"
  24. [ -n "$JENKINS_DEBUG_LEVEL" ] && PARAMS="$PARAMS --debug=$JENKINS_DEBUG_LEVEL"
  25. [ -n "$JENKINS_HANDLER_STARTUP" ] && PARAMS="$PARAMS --handlerCountStartup=$JENKINS_HANDLER_STARTUP"
  26. [ -n "$JENKINS_HANDLER_MAX" ] && PARAMS="$PARAMS --handlerCountMax=$JENKINS_HANDLER_MAX"
  27. [ -n "$JENKINS_HANDLER_IDLE" ] && PARAMS="$PARAMS --handlerCountMaxIdle=$JENKINS_HANDLER_IDLE"
  28. [ -n "$JENKINS_ARGS" ] && PARAMS="$PARAMS $JENKINS_ARGS"
  29. if [ "$JENKINS_ENABLE_ACCESS_LOG" = "yes" ]; then
  30. PARAMS="$PARAMS --accessLoggerClassName=winstone.accesslog.SimpleAccessLogger --simpleAccessLogger.format=combined --simpleAccessLogger.file=/var/log/jenkins/access_log"
  31. fi
  32. ebegin "Starting ${SVCNAME}"
  33. start-stop-daemon --start --quiet --background \
  34. --make-pidfile --pidfile $JENKINS_PIDFILE \
  35. --user ${JENKINS_USER} \
  36. --exec "${COMMAND}" -- $JAVA_PARAMS $PARAMS
  37. eend $?
  38. }
  39. stop() {
  40. ebegin "Stopping ${SVCNAME}"
  41. start-stop-daemon --stop --quiet --pidfile $JENKINS_PIDFILE
  42. eend $?
  43. }