Scene:
1. Hudson as a continuous integration software, it is necessary to deploy in a Java Web container to use, generally the most commonly used is tomcat.
2. It is easy for Tomcat to deploy installation Services on Windows, with the use of its own bat file to install successfully, and the trouble is that the documentation is not installed under Mac OS X.
3. Mac OS x is initiated using daemon and can also be understood as a service.
4. Typically execute startup.sh to start, and then add the startup file startup.sh to the login entry in the user and group, current user, but you must also set up automatic login. The disadvantage is: 1) unsafe, the server automatically log on. 2) This mode will pop up a command-line window, start more than a few times there will be a lot of windows to close themselves, affecting the use of other interface tools, so here is the use of services to start, the online information seems to be very small.
5. If it is just for installation, just look at the first part; in-depth understanding can be seen in the second part.
Part I: Installation Services
1. Installation Services, in fact, if configured plist, only need this step to add the start-up service.
sudo cp org.apache.tomcat.plist/library/launchdaemons/
Org.apache.tomcat.plist File Contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>org.apache.tomcat</string>
<key>ProgramArguments</key>
<array>
<string>/Users/apple/Desktop/apache-tomcat-5.5.25/bin/catalina.sh</string>
<string>run</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>JAVA_HOME</key>
<string>/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home</string>
</dict>
<key>RunAtLoad</key>
<true/>
<!--
<key>StandardOutPath</key>
<string>/Users/apple/stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/apple/stderr.log</string>
-->
</dict>
</plist>
Custom section:
--Programarguments
This is modified to the full catalina.sh path/users/apple/desktop/apache-tomcat-5.5.25/bin/catalina.sh
--Java_home
This can only be an absolute path, not known on the command line using '/usr/libexec/java_home ' to get. Reference articles on the installation of Jdk1.7:
http://blog.csdn.net/infoworld/article/details/44677719
2. Test start-up service
Load the configuration file.
Launchctl load/library/launchdaemons/org.apache.tomcat.plistlaunchctl Start Org.apache.tomcat
3. After the start, you can open http://localhost:8080 see our familiar big face cat:
4. If you cannot open the Tomcat home page, turn on the output in the plist (set the path, remove the comment)
Standardoutpath
Standarderrorpath
5. If the Test start service is successful, then restarting the computer should be self-booting.
Note: Each time you modify the plist file, you need to stop,remove (see below) Org.apache.tomcat load (see 2nd Step) This plist to take effect.
The second part: Manual testing Service, to start the service in the way of the command quickly, mainly write plist before the verification.
Launchctl:
1. Quickly verify that the startup service is running successfully and does not need to replicate org.apache.tomcat.plist to/library/launchdaemons/, meaning to quickly verify that a program that needs to be deployed is running correctly. Of course the configuration should be the same as plist.
Launchctl submit-l org.apache.tomcat-o ' pwd '/stdout.log-e ' pwd '/stderr.log-p/users/apple/desktop/ Apache-tomcat-5.5.25/bin/catalina.sh Run
2. Stop the Service
Launchctl Stop Org.apache.tomcat
3. Remove the service from the current job
Launchctl Remove Org.apache.tomcat
4. Warning Error launchctl run Error:file exists
Indicates that the job has been started and needs to be stopped and removed before it can be rerun.
Launchctl Stop Org.apache.tomcatlaunchctl Remove Org.apache.tomcat
5. The configured output hint error indicates that the JAVA_HOME environment variable is not configured.
Neither the Java_home nor the jre_home environment variable is definedat least one of these environment variable is needed To run the This program
6. Setting Environment variables
Launchctl setenv java_home '/usr/libexec/java_home '
7. Delete environment variables
Launchctl unsetenv Java_home
Reference Documentation:
Http://wiki.apache.org/tomcat/TomcatOnMacOS
Https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/launchctl.1.html#//apple_ Ref/doc/man/1/launchctl
Https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
[Macosx]_[launchdaemons]_[mac OS X installation Tomcat boot service One of the methods]