2

如何在 Mac OS X 系统上在不同的 HTTP 端口(即 7070 和 7071)上运行 Jenkins 的两个守护进程。

1)我为每个 dameon 创建了两个帐户,包含 Jenkins 主目录:jeankins1、jenkins2

2) 我复制了默认的 dameon 配置文件

sudo cp /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchDaemons/jenkins-dameon-1.plist
sudo cp /Library/LaunchDaemons/org.jenkins-ci.plist /Library/LaunchDaemons/jenkins-dameon-2.plist

3)我修改了dameon配置文件

sudo vi /Library/LaunchDaemons/jenkins-dameon-1.plist

jenkins-dameon-1.plist 文件的内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>EnvironmentVariables</key>
        <dict>
                <key>JENKINS_HOME</key>
                <string>/Users/jenkins1/Jenkins/Home</string>
        </dict>
        <key>GroupName</key>
        <string>wheel</string>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>org.jenkins-ci</string>
        <key>ProgramArguments</key>
        <array>
                <string>/bin/bash</string>
                <string>/Library/Application Support/Jenkins/jenkins-runner.sh</string>
                <string>--httpPort=7070</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>jenkins1</string>
        <key>SessionCreate</key>
        <true />
</dict>

sudo vi /Library/LaunchDaemons/jenkins-dameon-2.plist

jenkins-dameon-2.plist 文件的内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>EnvironmentVariables</key>
        <dict>
                <key>JENKINS_HOME</key>
                <string>/Users/jenkins2/Jenkins/Home</string>
        </dict>
        <key>GroupName</key>
        <string>wheel</string>
        <key>KeepAlive</key>
        <true/>
        <key>Label</key>
        <string>org.jenkins-ci</string>
        <key>ProgramArguments</key>
        <array>
                <string>/bin/bash</string>
                <string>/Library/Application Support/Jenkins/jenkins-runner.sh</string>
                <string>--httpPort=7071</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
        <key>UserName</key>
        <string>jenkins2</string>
        <key>SessionCreate</key>
        <true />
</dict>

4) 我启动了两个 Jenkins 守护进程

sudo launchctl load /Library/LaunchDaemons/jenkins-dameon-1.plist
sudo launchctl load /Library/LaunchDaemons/jenkins-dameon-2.plist

我传递 httpPort 参数的方式似乎不正确,怎么办?

此解决方案仅适用于一个实例:Configure Jenkins Mac OS X native package to run in a different port

4

2 回答 2

2

在我的 PLIST 文件中,我不再使用 jenkins-runner.sh 脚本,而是使用 java 可执行文件。

jenkins-dameon-1.plist 文件的内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>EnvironmentVariables</key>
    <dict>
        <key>JENKINS_HOME</key>
        <string>/Users/jenkins1/Jenkins/Home</string>
    </dict>
    <key>GroupName</key>
    <string>daemon</string>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>jenkins1</string>
    <key>ProgramArguments</key>
    <array>
                <string>/usr/bin/java</string>
                <string>-jar</string>
                <string>/Applications/Jenkins/jenkins.war</string>
                <string>--httpPort=7070</string>
                <string>--ajp13Port=-1</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>UserName</key>
    <string>jenkins1</string>
        <key>SessionCreate</key>
    <true />
</dict>
</plist>

jenkins-dameon-2.plist 文件的内容:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>EnvironmentVariables</key>
    <dict>
        <key>JENKINS_HOME</key>
        <string>/Users/jenkins2/Jenkins/Home</string>
    </dict>
    <key>GroupName</key>
    <string>daemon</string>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>jenkins2</string>
    <key>ProgramArguments</key>
    <array>
                <string>/usr/bin/java</string>
                <string>-jar</string>
                <string>/Applications/Jenkins/jenkins.war</string>
                <string>--httpPort=7071</string>
                <string>--ajp13Port=-1</string>
    </array>
    <key>RunAtLoad</key>
    <false/>
    <key>UserName</key>
    <string>jenkins2</string>
        <key>SessionCreate</key>
    <true />
</dict>
</plist>
于 2012-08-16T12:47:07.243 回答
1

作为 OSX 安装的一部分,创建了 3 个文件用于启动:

  1. /Library/Preferences/org.jenkins-ci.plist
  2. /Library/Application\ Support/Jenkins/jenkins-runner.sh
  3. /图书馆/LaunchDaemons/org.jenkins-ci.plist

要正确执行此操作,您需要复制所有 3 个文件并对其进行编辑。

文件 1 是您可以设置端口的地方。为此,您需要使用此处所述的默认命令(将文件名更改为您的副本):https ://wiki.jenkins-ci.org/display/JENKINS/Thanks+for+using+OSX+Installer

文件 2 是启动 Jenkins 并读取默认值的 shell 脚本。编辑您的文件副本以指向您在 defaults= 行中的文件 1 的副本(减去 .plist 扩展名)。

文件 1 控制守护程序的启动。您可以将其编辑为:

  • 指向文件 2 的副本,而不是原始的 shell 脚本
  • 如果需要,指向不同的日志目录以进行标准输出
  • 如果需要,为标准错误指向不同的日志目录
  • 指向不同的 JENKINS_HOME 目录
  • 更改标签以反映您的新文件名
  • 如果需要,指定不同的用户

然后,您应该拥有在不同端口上启动 2 个不同守护程序所需的一切。

于 2013-10-09T23:00:33.080 回答