macos 如何在 OS X 上安装 Hudson 作为服务?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3715606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:13:00  来源:igfitidea点击:

How to install Hudson as a service on OS X?

macoshudsonjenkins

提问by sorin

Running hudsonit is easy but currently the documentation is missing the tutorial for installing an running hudson as a daemon/service on OS X.

运行hudson很容易,但目前文档缺少在 OS X 上安装运行 hudson 作为守护程序/服务的教程。

When you switch to production you need to assure that it is properly configured and secured.

当您切换到生产时,您需要确保正确配置和保护它。

Requirements:

要求:

  • be able to run it on port 80
  • not running as root (or at least not running the jobs as root)
  • assure that it does properly start/stop on system restarts
  • enable auto-upgrade, that works directly from the web interface.
  • 能够在端口 80 上运行它
  • 不以 root 身份运行(或至少不以 root 身份运行作业)
  • 确保它在系统重新启动时正确启动/停止
  • 启用自动升级,直接从网络界面工作。

The best, would be to have an installation script that downloads latest hudson and installs it.

最好的办法是有一个安装脚本来下载最新的 hudson 并安装它。

We'll integrate the best answer to Hudson wiki.

我们会将最佳答案整合到 Hudson wiki。

Resources:

资源:

采纳答案by sorin

The correct solution is to install hudson inside tomcat and make tomcat run as daemon

正确的解决办法是在tomcat里面安装hudson,让tomcat作为守护进程运行

This will also meet the security requirements and allow you to upgrade hudson with ease.

这也将满足安全要求,并允许您轻松升级 hudson。

Here is the full guide for OS X 10.6: https://serverfault.com/questions/183496/full-guide-for-installing-tomcat-on-os-x/183527#183527

这是 OS X 10.6 的完整指南:https: //serverfault.com/questions/183496/full-guide-for-installing-tomcat-on-os-x/183527#183527

回答by Joe McMahon

If you want a local Hudson to run on your Mac whenever you log in, try this.

如果您希望每次登录时都在 Mac 上运行本地 Hudson,请尝试此操作。

You'll want to set up a launchctl plist for it; that should look something like this:

你需要为它设置一个launchctl 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>UserName</key>
 <string>yourid</string>
 <key>Label</key>
 <string>Hudson</string>
 <key>EnvironmentVariables</key>
   <dict>
     <key>HUDSON_HOME</key>
     <string>/Users/yourid/.hudson</string>
   </dict>
 <key>ProgramArguments</key>
 <array>
 <string>/usr/bin/java</string>
 <string>-jar</string>
 <string>/Users/yourid/Hudson/hudson.war</string>
 </array>
 <key>RunAtLoad</key>
 <true/>
</dict>
</plist>

This assumes you've downloaded hudson.warto your home directory under ~/Hudson, and that you want to run it as yourself (probably the best decisions.) Be sure that you define the <UserName>key or it will run as root!

这假设您已经下载hudson.war到您的主目录下的~/Hudson,并且您想以自己的身份运行它(可能是最好的决定)。请确保您定义了<UserName>密钥,否则它将以 root 身份运行!

Starting on login

从登录开始

  1. Save the above as /Library/LaunchAgents/hudson.plist
  2. Start it the first time with

    sudo launchctl load -w /Library/LaunchAgents/hudson.plist

  1. 将以上内容另存为 /Library/LaunchAgents/hudson.plist
  2. 第一次启动它

    sudo launchctl load -w /Library/LaunchAgents/hudson.plist

or log out and back in, which will do the same thing automatically.

或注销并重新登录,这将自动执行相同的操作。

Starting on reboot

重新启动时开始

  1. Save the above as /Library/LaunchDaemons/hudson.plist
  2. Start it the first time with

    sudo launchctl load -w /Library/LaunchDaemons/hudson.plist

  1. 将以上内容另存为 /Library/LaunchDaemons/hudson.plist
  2. 第一次启动它

    sudo launchctl load -w /Library/LaunchDaemons/hudson.plist

or reboot your machine, which will do the same thing automatically.

或者重启你的机器,它会自动做同样的事情。

Restarting Hudson

重启哈德逊

Hudson can't automatically restart under OS X, so if you need to stop it, issue the restart command

Hudson 在 OS X 下不能自动重启,所以如果你需要停止它,发出重启命令

launchctl unload -w path_to_plist

I have found that sometimes it doesn't stop on the first execution of launchctl unload; in those cases just issue the command again.

我发现有时它不会在第一次执行时停止launchctl unload;在这些情况下,只需再次发出命令。

This will run under port 8080 as if you had run the command from the command line yourself, using the Winstone server built in to the .warfile.

这将在端口 8080 下运行,就像您自己从命令行运行命令一样,使用.war文件中内置的 Winstone 服务器。

I realize this doesn't specifically answer the "run it on port 80" question, but for development on your own laptop, I suggest that this is a better option.

我意识到这并没有专门回答“在端口 80 上运行”问题,但是对于在您自己的笔记本电脑上进行开发,我建议这是一个更好的选择。

回答by Danny Staple

The tiny solution I had (which also starts at login) was this: First run hudson manually once (so it builds it's .hudson dir). create a hudson.commandfile somewhere on your machine in OSX with content a little like this:

我的小解决方案(也从登录开始)是这样的:首先手动运行 hudson 一次(因此它构建它的 .hudson 目录)。在你的 OSX 机器上的某个地方创建一个hudson.command文件,内容有点像这样:

nohup java -jar .hudson/hudson.war --httpPort=8080 &

Then, open up system preferences, select your user, and then Login Items. Click the "+" button, and you'll be able to select the command with finder.

然后,打开系统首选项,选择您的用户,然后选择登录项目。单击“+”按钮,您将能够使用 finder 选择命令。

Next time you log in, hudson will have started.

下次登录时,hudson 将启动。

Disadvantages:

缺点:

  • Hudson has no specific user - it's just you
  • hudson is on port 8080
  • Hudson restarts mean finding the process, killing it and starting the hudson.command file again.
  • Hudson starts only once a user has logged in.
  • Hudson 没有特定用户 - 只有你
  • 哈德森在端口 8080
  • Hudson 重启意味着找到进程,杀死它并再次启动 hudson.command 文件。
  • Hudson 仅在用户登录后启动。