Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

War Conversion #4

Closed
wants to merge 2 commits into from

6 participants

@damm

AJ,

My apologies about getting this to you in a timely manner. I likely did a few :/ things but overall should be good enough.

Thanks

damm added some commits
@damm damm Convert the Jenkins cookbook to use the WAR instead of the Debian pac…
…kage due to UCF reasons

Signed-off-by: Scott M. Likens <scott@likens.us>
e5e0df8
@damm damm this is a markdown file 3492682
@webframp

looks pretty good, thanks! Hopefully AJ can review today when he comes online

@fujin

I'm not super keen on this shipping an init script -- mostly because I'd have to maintain it. How about Runit?

Some of the other changes we specifically adjusted from earlier versions of this cookbook have slipped back in. Thanks for the PR, will work through it.

@damm

Perfectly fine, I don't have time today to get to it today so i'll have find time this weekend hopefully.

@fujin

May just accept this as is and internalize the modifications I have proposed if you don't have the time for it -- then we can cut a new version and release it once we have both reviewed. Sound good?

@damm

sounds good

@guilhem

Sorry but the apt way to install MUST be the default for debian and Ubuntu.

If you want a manual way to install, chef is enough powerful to let you choose an option for it.

@gregsymons

Then submit a patch to do so. This changes from using the Jenkins apt-repo (not the ubuntu or debian default repo) to install to using the war file. If I understand damm's commit comment, the Jenkins apt package had some issues with preserving user configuration changes as a good package should.

The Ubuntu package is significantly out of date with respect to the stable Jenkins release (1.409.1 on oneiric vs. 1.447.1 on the jenkins website as of today) . I'd prefer to be using a recent version of Jenkins, myself. Also, apt and applications with plugins don't play that well together, IMO. Finally, the Ubuntu package deploys Jenkins inside of Tomcat rather than running the standalone war, which just adds unnecessary system dependencies.

@guilhem

I use the Jenkins apt package since a long time in production (for debian and ubuntu) and I don't see any problems (with many plugins / configurations / nodes ...)

Maybe some more information can be a good start !

PS : jenkins package is only a package with init.d, logrotate, logfolder create, run folder... AND .war file.
This patch do exactly the same work as the package... but without the strength of an apt package and with duplicate work.
( have a look with file-roller or 7zip... to this file it's quite easy to understand : http://pkg.jenkins-ci.org/debian/binary/jenkins_1.466_all.deb )

@damm

When you modify /etc/default/jenkins you need to apply UCF rules to purge it from the list or when the cookbook tries to run apt-get install jenkins again (Upgrade?) you should get a prompt to accept or reject changes to /etc/default/jenkins.

This behavior does not work properly in Chef and can cause you to have to run apt-get -f install and manually clean it up before the packaging system is useable again.

Now we can patch the UCF Behavior in the Chef recipe to work around that. However I was told that the WAR Pull request would be gladly accepted as that would help make this cookbook work for a wider audience.

@fujin if your still running low on time I can work in some time now to make it work under runit.

Thanks

@guilhem

it's the same problem for ALL the apt packages. Glad that everyone don't bypass it with runit.

runit is a good things in option (any new feature is a good thing), but the apt-package must be the rule (maybe with options "--force-yes").

@damm

@guilhem --force-yes isn't valid here. If you read the above comment I mention how to fix the problem. As this pull request hasn't been accepted yet is there anything we can help you here with? or did you just want to voice your opinion that the war package isn't valid?

@guilhem

IMPOV, your patch must be like this :
in default :

if(node[:jenkins][:install_method] == 'war')
  include_recipe 'jenkins::war'
else

in attribute.rb ->

default[:jenkins][:install_method] = 'package'

see nginx official cookbook for a functionnal example.

of course all you work must be in the recipe "war.rb"

@damm

If you wish to enact your opinion you should fork said cookbook and make that change yourself and then re-submit the pull request. However I don't see what value your adding here at this time?

@guilhem

I don't need your patch, at the opposite, your patch break ALL the current install of anyone.

So patch it in a good way for all (as a pull request must be) and everyone will be happy.

@gregsymons gregsymons commented on the diff
recipes/default.rb
@@ -198,3 +172,12 @@
end
end
end
+service "jenkins" do
+ supports [ :stop, :start, :restart, :status ]
+ status_command "test -f #{pid_file} && kill -0 `cat #{pid_file}`"
+ action [:start,:enable]
+end
+execute "start jenkins" do

I'm a little confused by this execute block here. Why do we have to explicitly try to start it? Shouldn't that be handled by the service block directly above? Also, why do we now have two service blocks?

@fujin
fujin added a note

These'll be purged when I add the s6 supervisor support. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fujin

@guilhem while I appreciate your interaction with the community none of your suggestions mirror any of Heavy Water's practices or principles or even client request approximations. We have many disparage installations of Pennyworth and managing them all via .WAR will reduce significant complexity -- it was my intention to complete this work eventually regardless ("on the roadmap").

One of our major gripes with the upstream packages is the extraneous junk they include and of course the implicit behaviour of starting the service, leading us to perform multiple tricks during the automation to install plugins and restart Jenkins and then poll it until it is correctly available. With a WAR, we'd simply put the plugin on disk before warming up Jenkins -- the package wouldn't auto start it and need to be restarted, polled, etc.

I'll be pulling in the other outstanding patches, pulling this in, and modifying it to use the s6 skarnet's small and secure software supervision suite instead of Runit, to match the rest of our supervised services. [0][1]

Eventually Heavy Water will offer a public repository for s6 packages statically compiled for Debian/Ubuntu, instead of our current compile-from-source model (even though it is incredibly fast and lightweight, I'd prefer not to rely on compilation at all)

Thanks for playing along!

[0] http://www.skarnet.org/software/s6/
[1] https://github.com/heavywater/chef-s6

@guilhem

@fujin I understand your needs. OpenSource is the place where everyone can find his happiness.
However, your needs aren't all needs (as mine).

Separate your work in a "war" recipe that you can call with an attribute or directly recipe is a good solution IMPOV.
If you need some help, don't hesitate. (But when I see your work, I'm sure that it will not take to much time ^^)

For s6, I will have a look to it. But for the moment I migrate many of my services to upstart (for the "beauty" of his conf files) and, when Ubuntu will include it, to systemd for its cgroup capability...
Yet Another Init Alternative... too much for me :)

@fujin

@guilhem thanks for your input. for a time, we will adopt a model as you suggested, supporting multiple installation methods. the Package based installation method will be deprecated and we will likely not devote resources to enhancing it any further and will make use of WAR internally. Perhaps I'll abstract the service supervisor portion as well.

@patcon patcon commented on the diff
attributes/default.rb
@@ -36,7 +36,7 @@
end
default[:jenkins][:server][:port] = 8080
-default[:jenkins][:server][:host] = node[:fqdn]
+default[:jenkins][:server][:host] = "0.0.0.0"
@patcon
patcon added a note

double-plus-good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@patcon patcon commented on the diff
recipes/default.rb
@@ -145,20 +122,17 @@
action :nothing
end
-log "jenkins: install and start" do
- notifies :install, "package[jenkins]", :immediately
- notifies :start, "service[jenkins]", :immediately unless install_starts_service
- notifies :create, "ruby_block[block_until_operational]", :immediately
- not_if do
- File.exists? "/usr/share/jenkins/jenkins.war"
- end
-end
-
template "/etc/default/jenkins"
@patcon
patcon added a note

does this needs a notifies :restart, "service[jenkins]" or something, or is this one of the benefits of using WAR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@patcon

When you modify /etc/default/jenkins you need to apply UCF rules to purge it from the list or when the cookbook tries to run apt-get install jenkins again (Upgrade?) you should get a prompt to accept or reject changes to /etc/default/jenkins.

This behavior does not work properly in Chef and can cause you to have to run apt-get -f install and manually clean it up before the packaging system is useable again.

Hey @damm, I totally get that the WAR makes sense for now, but think we could try to make some headway on helping the jenkins package maintainers fix the issue? This is new territory for me, so wondering if it's known to be a slow process, or something like that

Thanks guys!

@patcon
8:15p - patcon:
hey guys, wondering who the debian package maintainer is for the official jenkins package repo
8:15p - patcon:
trying to figure out whether these sysadmin concerns might be able to be dealt with: https://github.com/heavywater/chef-jenkins/pull/4#issuecomment-6011742
8:15p - kohsuke:
patcon: one in Ubuntu is jamespage. pkg.jenkins-ci.org is me
8:16p - patcon:
thanks kohsuke. are you familiar with the concern about /etc/default/jenkins and UCF behavior?
8:17p - patcon:
• patcon is parroting the sysadmins who actually understand the issue :)
8:17p - patcon:
kohsuke: but happy to do some learning to figure out a solution, if possible
8:17p - kohsuke:
patcon: no, I'm not familiar with UCF
8:17p - kohsuke:
let me read it
8:18p - patcon:
kohsuke: it's long. you're busy. I'll let them know you'll give it an ear, and see if they can summarize later
8:18p - kohsuke:
I'm willing to merge pull requests to the debian packages so long as those who know what they are doing can vouch for it
8:18p - patcon:
dealio. thanks kohsuke

Anyone intersested in this approach in the longterm? Fix the issue at it's origins? As I said, I'll take a stab, but if someone understands the relevant components and can do it in their sleep...

Cheers

@fujin
@patcon patcon referenced this pull request in phlipper/chef-percona
Closed

my.cnf custom settings, mysqld fails to start #20

@fujin fujin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 12, 2012
  1. @damm

    Convert the Jenkins cookbook to use the WAR instead of the Debian pac…

    damm authored
    …kage due to UCF reasons
    
    Signed-off-by: Scott M. Likens <scott@likens.us>
Commits on Apr 13, 2012
  1. @damm

    this is a markdown file

    damm authored
This page is out of date. Refresh to see the latest.
View
27 README.md
@@ -1,7 +1,14 @@
Description
===========
+
Installs and configures Jenkins CI server & node slaves. Resource providers to support automation via jenkins-cli, including job create/update.
+Changelog
+=========
+
+- 0.7 - Jenkins was binding to the ip address of the primary interface instead of listening to all addresses which caused nginx to be unable to connect over localhost to Jenkins.
+- 0.8 - Convert the recipe to use only the WAR file and not the Debian package.
+
Requirements
============
@@ -40,9 +47,10 @@ Where the jenkins_login recipe is simply:
jenkins_cli "login --username #{node[:jenkins][:username]} --password #{node[:jenkins][:password]}"
Attributes
-==========
+----------
-* jenkins[:mirror] - Base URL for downloading Jenkins (server)
+* jenkins[:version] - Specify the version of jenkins used. By default it is latest
+* jenkins[:mirror_url] - Specify the URL to download the WAR from
* jenkins[:java_home] - Java install path, used for for cli commands
* jenkins[:server][:home] - JENKINS_HOME directory
* jenkins[:server][:user] - User the Jenkins server runs as
@@ -69,7 +77,7 @@ Attributes
* jenkins[:node][:ssh_private_key] - jenkins master defaults to: `~/.ssh/id_rsa` (created by the default recipe)
* jenkins[:node][:jvm_options] - SSH slave JVM options
* jenkins[:iptables_allow] - if iptables is enabled, add a rule passing 'jenkins[:server][:port]'
-* jenkins[:nginx][:http_proxy][:variant] - use `nginx` or `apache2` to proxy traffic to jenkins backend (`nil` by default)
+* jenkins[:http_proxy][:variant] - use `nginx` or `apache2` to proxy traffic to jenkins backend (`nil` by default)
* jenkins[:http_proxy][:www_redirect] - add a redirect rule for 'www.*' URL requests ("disable" by default)
* jenkins[:http_proxy][:listen_ports] - list of HTTP ports for the HTTP proxy to listen on ([80] by default)
* jenkins[:http_proxy][:host_name] - primary vhost name for the HTTP proxy to respond to (`node[:fqdn]` by default)
@@ -77,12 +85,12 @@ Attributes
* jenkins[:http_proxy][:client_max_body_size] - max client upload size ("1024m" by default, nginx only)
Usage
-=====
+-----
'default' recipe
----------------
-Installs a Jenkins CI server using the http://jenkins-ci.org/redhat RPM. The recipe also generates an ssh private key and stores the ssh public key in the node 'jenkins[:pubkey]' attribute for use by the node recipes.
+Installs a Jenkins CI server using the http://jenkins-ci.org/war-stable WAR. The recipe also generates an ssh private key and stores the ssh public key in the node 'jenkins[:pubkey]' attribute for use by the node recipes.
'node_ssh' recipe
-----------------
@@ -117,8 +125,8 @@ Uses the nginx::source recipe from the nginx cookbook to install an HTTP fronten
Uses the apache2 recipe from the apache2 cookbook to install an HTTP frontend proxy. To automatically activate this recipe set the `node[:jenkins][:http_proxy][:variant]` to `apache2`.
-'jenkins_cli' resource provider
-------------------------------
+'jenkins_cli' resource provider
This resource can be used to execute the Jenkins cli from your recipes. For example, install plugins via update center and restart Jenkins:
@@ -175,14 +183,14 @@ The script to generate groovy that manages a node can be used standalone. For e
% ruby manage_node.rb name slave-hostname remote_fs /home/jenkins ... | java -jar jenkins-cli.jar -s http://jenkins:8080/ groovy =
Issues
-======
+------
* CLI authentication - http://issues.jenkins-ci.org/browse/JENKINS-3796
* CLI *-node commands fail with "No argument is allowed: nameofslave" - http://issues.jenkins-ci.org/browse/JENKINS-5973
-License & Author
-================
+License & Author(s):
+-------------------
This is a downstream fork of Doug MacEachern's Hudson cookbook (https://github.com/dougm/site-cookbooks) and therefore deserves all the glory.
@@ -192,6 +200,7 @@ Contributor:: AJ Christensen <aj@junglist.gen.nz>
Contributor:: Fletcher Nichol <fnichol@nichol.ca>
Contributor:: Roman Kamyk <rkj@go2.pl>
Contributor:: Darko Fabijan <darko@renderedtext.com>
+Contributor:: Scott Likens <scott@likens.us>
Copyright:: 2010, VMware, Inc
View
6 attributes/default.rb
@@ -21,8 +21,8 @@
# limitations under the License.
#
-default[:jenkins][:mirror] = "http://mirrors.jenkins-ci.org"
-default[:jenkins][:package_url] = "http://pkg.jenkins-ci.org"
+default[:jenkins][:version]="latest"
+default[:jenkins][:mirror_url] = "http://mirrors.jenkins-ci.org/war-stable"
default[:jenkins][:java_home] = ENV['JAVA_HOME']
default[:jenkins][:server][:home] = "/var/lib/jenkins"
@@ -36,7 +36,7 @@
end
default[:jenkins][:server][:port] = 8080
-default[:jenkins][:server][:host] = node[:fqdn]
+default[:jenkins][:server][:host] = "0.0.0.0"
@patcon
patcon added a note

double-plus-good!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
default[:jenkins][:server][:url] = "http://#{node[:jenkins][:server][:host]}:#{node[:jenkins][:server][:port]}"
default[:jenkins][:iptables_allow] = "disable"
View
8 metadata.rb
@@ -1,9 +1,9 @@
- maintainer "AJ Christensen"
+maintainer "AJ Christensen"
maintainer_email "aj@junglist.gen.nz"
license "Apache 2.0"
description "Installs and configures Jenkins CI server & slaves"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version "0.6.3"
+version "0.8"
-%w(runit java).each { |cb| depends cb }
-%w(iptables yum apt).each { |cb| recommends cb }
+%w(runit java nginx).each { |cb| depends cb }
+%w(iptables apt).each { |cb| recommends cb }
View
1  providers/cli.rb
@@ -49,5 +49,6 @@ def action_run
jenkins_execute command do
cwd home
block { |stdout| new_resource.block.call(stdout) } if new_resource.block
+ only_if new_resource.only_if
end
end
View
3  providers/job.rb
@@ -48,9 +48,10 @@ def post_job(url)
res.error! unless res.kind_of?(Net::HTTPSuccess)
end
+#could also use: jenkins_cli "create-job #{@new_resource.job_name} < #{@new_resource.config}"
def action_create
unless job_exists
- jenkins_cli "create-job #{@new_resource.job_name} < #{@new_resource.config}"
+ post_job(new_job_url)
end
end
View
81 recipes/default.rb
@@ -3,6 +3,7 @@
# Based on hudson
# Recipe:: default
#
+# Author:: Scott Likens <scott@likens.us>
# Author:: AJ Christensen <aj@junglist.gen.nz>
# Author:: Doug MacEachern <dougm@vmware.com>
# Author:: Fletcher Nichol <fnichol@nichol.ca>
@@ -21,7 +22,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
+pid_file = "/var/run/jenkins/jenkins.pid"
pkey = "#{node[:jenkins][:server][:home]}/.ssh/id_rsa"
tmp = "/tmp"
@@ -65,43 +66,25 @@
backup false
owner node[:jenkins][:server][:user]
group node[:jenkins][:server][:group]
- action :create_if_missing
end
end
-case node.platform
-when "ubuntu", "debian"
- include_recipe "apt"
- include_recipe "java"
-
- pid_file = "/var/run/jenkins/jenkins.pid"
- install_starts_service = true
-
- apt_repository "jenkins" do
- uri "#{node.jenkins.package_url}/debian"
- components %w[binary/]
- key "http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key"
- action :add
- end
-when "centos", "redhat"
- include_recipe "yum"
-
- pid_file = "/var/run/jenkins.pid"
- install_starts_service = false
-
- yum_key "jenkins" do
- url "#{node.jenkins.package_url}/redhat/jenkins-ci.org.key"
- action :add
- end
+directory "/usr/share/jenkins" do
+ action :create
+ owner "nobody"
+ group "nogroup"
+ recursive true
+end
- yum_repository "jenkins" do
- description "repository for jenkins"
- url "#{node.jenkins.package_url}/redhat/"
- key "jenkins"
- action :add
- end
+remote_file "/usr/share/jenkins/jenkins.war" do
+ source "#{node[:jenkins][:mirror_url]}/#{node[:jenkins][:version]}/jenkins.war"
+ owner "root"
+ group "root"
+ mode 0644
end
+package "daemon"
+include_recipe "java"
#"jenkins stop" may (likely) exit before the process is actually dead
#so we sleep until nothing is listening on jenkins.server.port (according to netstat)
ruby_block "netstat" do
@@ -119,12 +102,6 @@
action :nothing
end
-service "jenkins" do
- supports [ :stop, :start, :restart, :status ]
- status_command "test -f #{pid_file} && kill -0 `cat #{pid_file}`"
- action :nothing
-end
-
ruby_block "block_until_operational" do
block do
until IO.popen("netstat -lnt").entries.select { |entry|
@@ -145,20 +122,17 @@
action :nothing
end
-log "jenkins: install and start" do
- notifies :install, "package[jenkins]", :immediately
- notifies :start, "service[jenkins]", :immediately unless install_starts_service
- notifies :create, "ruby_block[block_until_operational]", :immediately
- not_if do
- File.exists? "/usr/share/jenkins/jenkins.war"
- end
-end
-
template "/etc/default/jenkins"
@patcon
patcon added a note

does this needs a notifies :restart, "service[jenkins]" or something, or is this one of the benefits of using WAR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
-package "jenkins" do
+template "/etc/init.d/jenkins" do
+ source "jenkins"
+ mode 0755
+end
+
+service "jenkins" do
+ supports [ :stop, :start, :restart, :status ]
+ status_command "test -f #{pid_file} && kill -0 `cat #{pid_file}`"
action :nothing
- notifies :create, "template[/etc/default/jenkins]", :immediately
end
# restart if this run only added new plugins
@@ -198,3 +172,12 @@
end
end
end
+service "jenkins" do
+ supports [ :stop, :start, :restart, :status ]
+ status_command "test -f #{pid_file} && kill -0 `cat #{pid_file}`"
+ action [:start,:enable]
+end
+execute "start jenkins" do

I'm a little confused by this execute block here. Why do we have to explicitly try to start it? Shouldn't that be handled by the service block directly above? Also, why do we now have two service blocks?

@fujin
fujin added a note

These'll be purged when I add the s6 supervisor support. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ command "/etc/init.d/jenkins start"
+ not_if 'ps auxwww | grep [j]enkins'
+end
View
3  recipes/proxy_nginx.rb
@@ -54,3 +54,6 @@
enable false
end
end
+service "nginx" do
+ action [:start, :enable]
+end
View
243 templates/default/jenkins
@@ -0,0 +1,243 @@
+#!/bin/bash
+# /etc/init.d/jenkins
+# debian-compatible jenkins startup script.
+# Amelia A Lewis <alewis@ibco.com>
+#
+### BEGIN INIT INFO
+# Provides: jenkins
+# Required-Start: $remote_fs $syslog $network
+# Required-Stop: $remote_fs $syslog $network
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start jenkins at boot time
+# Description: Controls the jenkins continuous integration engine.
+### END INIT INFO
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+
+DESC="Jenkins Continuous Integration Server"
+NAME=jenkins
+SCRIPTNAME=/etc/init.d/$NAME
+
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+#DAEMON=$JENKINS_SH
+DAEMON=/usr/bin/daemon
+DAEMON_ARGS="--name=$NAME --inherit --env=JENKINS_HOME=$JENKINS_HOME --output=$JENKINS_LOG --pidfile=$PIDFILE"
+
+SU=/bin/su
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Exit if not supposed to run standalone
+[ "$RUN_STANDALONE" = "false" ] && exit 0
+
+# load environments
+if [ -r /etc/default/locale ]; then
+ . /etc/default/locale
+ export LANG LANGUAGE
+elif [ -r /etc/environment ]; then
+ . /etc/environment
+ export LANG LANGUAGE
+fi
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+# Make sure we run as root, since setting the max open files through
+# ulimit requires root access
+if [ `id -u` -ne 0 ]; then
+ echo "The $NAME init script can only be run as root"
+ exit 1
+fi
+
+
+check_tcp_port() {
+ local service=$1
+ local assigned=$2
+ local default=$3
+
+ if [ -n "$assigned" ]; then
+ port=$assigned
+ else
+ port=$default
+ fi
+
+ count=`netstat --listen --numeric-ports | grep \:$port[[:space:]] | grep -c . `
+
+ if [ $count -ne 0 ]; then
+ echo "The selected $service port ($port) seems to be in use by another program "
+ echo "Please select another port to use for $NAME"
+ return 1
+ fi
+}
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # the default location is /var/run/jenkins/jenkins.pid but the parent directory needs to be created
+ mkdir `dirname $PIDFILE` > /dev/null 2>&1 || true
+ chown $JENKINS_USER `dirname $PIDFILE`
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ $DAEMON $DAEMON_ARGS --running && return 1
+
+ # Verify that the jenkins port is not already in use, winstone does not exit
+ # even for BindException
+ check_tcp_port "http" "$HTTP_PORT" "8080" || return 1
+
+ # If the var MAXOPENFILES is enabled in /etc/default/jenkins then set the max open files to the
+ # proper value
+ if [ -n "$MAXOPENFILES" ]; then
+ [ "$VERBOSE" != no ] && echo Setting up max open files limit to $MAXOPENFILES
+ ulimit -n $MAXOPENFILES
+ fi
+
+ # --user in daemon doesn't prepare environment variables like HOME, USER, LOGNAME or USERNAME,
+ # so we let su do so for us now
+ $SU -l $JENKINS_USER --shell=/bin/bash -c "$DAEMON $DAEMON_ARGS -- $JAVA $JAVA_ARGS -jar $JENKINS_WAR $JENKINS_ARGS" || return 2
+}
+
+
+#
+# Verify that all jenkins processes have been shutdown
+# and if not, then do killall for them
+#
+get_running()
+{
+ return `ps -U $JENKINS_USER --no-headers -f | egrep -e '(java|daemon)' | grep -c . `
+}
+
+force_stop()
+{
+ get_running
+ if [ $? -ne 0 ]; then
+ killall -u $JENKINS_USER java daemon || return 3
+ fi
+}
+
+# Get the status of the daemon process
+get_daemon_status()
+{
+ $DAEMON $DAEMON_ARGS --running || return 1
+}
+
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ get_daemon_status
+ case "$?" in
+ 0)
+ $DAEMON $DAEMON_ARGS --stop || return 2
+ # wait for the process to really terminate
+ for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
+ sleep 1
+ $DAEMON $DAEMON_ARGS --running || break
+ done
+ if get_daemon_status; then
+ force_stop || return 3
+ fi
+ ;;
+ *)
+ force_stop || return 3
+ ;;
+ esac
+
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return 0
+}
+
+case "$1" in
+ start)
+ log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) log_end_msg 0 ;;
+ 2) log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) log_end_msg 0 ;;
+ 2) log_end_msg 1 ;;
+ esac
+ ;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ status)
+ get_daemon_status
+ case "$?" in
+ 0)
+ echo "$DESC is running with the pid `cat $PIDFILE`"
+ rc=0
+ ;;
+ *)
+ get_running
+ procs=$?
+ if [ $procs -eq 0 ]; then
+ echo -n "$DESC is not running"
+ if [ -f $PIDFILE ]; then
+ echo ", but the pidfile ($PIDFILE) still exists"
+ rc=1
+ else
+ echo
+ rc=3
+ fi
+
+ else
+ echo "$procs instances of jenkins are running at the moment"
+ echo "but the pidfile $PIDFILE is missing"
+ rc=0
+ fi
+
+ exit $rc
+ ;;
+ esac
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+exit 0
Something went wrong with that request. Please try again.