如何使用launchd设置networking(端口8080)启动的按需服务

我试图在'ondemand'模式下运行一个服务,但我甚至无法使用launchctl来注册服务。

$ launchctl load /Library/LaunchDaemons/org.fossil-scm.fossil.plist bind(): Permission denied bind(): Permission denied $ 

由于我得到一个双“绑定”的错误,我相信我做了一些错误的套接字configuration中的套接字configuration。

如何使用launchd设置networking(端口8080)启动的按需服务?

launchd / launchctl / launchd.plist,TN2083守护程序和代理程序以及“创build启动的守护进程和代理程序”的apple dev文档在这方面有点薄。

 <?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>inetdCompatibility</key> <dict/> <key>Label</key> <string>org.fossil-scm.fossil</string> <key>KeepAlive</key> <false/> <key>RunAtLoad</key> <false/> <key>ProgramArguments</key> <array> <string>/usr/local/fossil/bin/fossil</string> <string>http</string> <string>/Users/spdegabrielle/fossil-local-repository/myclone.fossil</string> </array> <key>Sockets</key> <dict> <key>Listeners</key> <array> <dict> <key>SockFamily</key> <string>IPv4</string> <key>SockServiceName</key> <string>http-alt</string> <key>SockType</key> <string>stream</string> </dict> <dict> <key>SockFamily</key> <string>IPv6</string> <key>SockServiceName</key> <string>http-alt</string> <key>SockType</key> <string>stream</string> </dict> </array> </dict> <key>UserName</key> <string>root</string> </dict> </plist> 

注意:用户名被添加,因为我想也许我需要运行在/ Library / LaunchDaemons /,而不是我的首选位置〜/ Library / LaunchAgents

我想要将端口与8080端口关联,但似乎http-alt预计端口591:

 $ sudo cat /etc/services |grep http-alt http-alt 591/udp # FileMaker, Inc. - HTTP Alternate (see Port 80) http-alt 591/tcp # FileMaker, Inc. - HTTP Alternate (see Port 80) http-alt 8008/udp # HTTP Alternate http-alt 8008/tcp # HTTP Alternate http-alt 8080/udp # HTTP Alternate (see port 80) http-alt 8080/tcp # HTTP Alternate (see port 80) 

使用名称默认的http-alt是Filemaker(6!),只需将SockServiceName更改为8080或您select的端口即可。

我看到您正在尝试将进程附加到端口591(http-alt)。

在Mac OS X中(和其他的Unix一样),一个普通的用户不能在1024以下的端口上附加任何进程,只有root可以做这样的操作。

你的猜测是正确的,将plist移到/System/Library/LaunchDaemons的一般目录(因为这是在一个套接字中监听,这对plist来说是有意义的), sudo launchctl load进程