Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems
Java Linux

Running Jenkins Swarm client as a service via Upstart

Posted by Admin • Wednesday, December 21. 2016 • Category: DevOps, Java, Linux

This turned out to be fairly simple, with only one gotcha: do not follow the how-to's out there that tell you to use expect fork. The process doesn't technically fork. When I had that setting enabled, upstart commands would hang under very specific but repeatable conditions (if the process was killed externally).



So, here is my upstart conf file:


/etc/init/jenkins-slave.conf

  1. description "Jenkins Slave via Swarm"
  2. author "Me"
  3.  
  4. start on runlevel [3]
  5. stop on shutdown
  6.  
  7. setuid "MY_USER"
  8. setgid "MY_GROUP"
  9.  
  10. #expect fork  - do not enable this!
  11. respawn
  12. respawn limit unlimited
  13.  
  14. script
  15. cd /correct/directory
  16. java -jar  /path/to/swarm.jar SWARM_PARAMS 2>&1 >> LOG_FILE
  17. emit jenkinsslave_running
  18. end script
  19.  

Note that the log file is somewhat ineffective - I'm still getting stdout in /var/log/upstart/jenkins-slave.log but stderr in LOG_FILE

0 Trackbacks

  1. No Trackbacks

0 Comments

Display comments as (Linear | Threaded)
  1. No comments

Add Comment


You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.
Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
Markdown format allowed


Submitted comments will be subject to moderation before being displayed.