简体   繁体   English

如何在MacOS X上使用JSVC包装器将Java应用程序注册(安装)为服务

[英]How to register(install) as service java application with JSVC wrapper on MacOS X

I have an application which i want to run as service on MacOS X. I used JSVC as wrapper and currently it starts in console just fine, shutdown process is correct, etc. So now i have to register it as service. 我有一个要在MacOS X上作为服务运行的应用程序。我使用JSVC作为包装器,当前它可以在控制台中正常启动,关机过程正确,等等。所以现在我必须将其注册为服务。 Found some manuals, wrote .plist file. 找到一些手册,写了.plist文件。 Next i executed 接下来我执行

sudo launchctl load /Library/LaunchDaemons/my.service.plist
sudo launchctl start my.service

And nothing happened. 没有任何反应。 Service didn't started. 服务未启动。

plist contents: 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>Label</key>
<string>my.service</string>
<key>ProgramArguments</key>
<array>
<string>/servertest/MYService</string>
<string>-jvm</string>
<string>server</string>
<string>-outfile</string>
<string>out.txt</string>
<string>-errfile</string>
<string>err.txt</string>
<string>-verbose</string>
<string>-debug</string>
<string>-home</string>
<string>/System/Library/Frameworks/JavaVM.framework/Home</string>
<string>-cp</string>
<string>./lib/hsqldb.jar:./lib/my-wrapper.jar:./lib/commons-daemon-1.0.8.jar</string>
<string>my.service.DaemonMac</string>
</array>
<key>WorkingDirectory</key>
<string>/servertest</string>
<key>StandardOutPath</key>
<string>/servertest/stdout.log</string>
<key>StandardErrorPath</key>
<string>/servertest/stderr.log</string>
<key>KeepAlive</key>
<false/>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

What am i doing wrong? 我究竟做错了什么?

Okay, nobody knows, i guess. 好吧,我猜没人知道。 Anyway, i handled it myself. 无论如何,我自己处理。 Here's example which worked for me: 这是对我有用的示例:

<?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>KeepAlive</key>
    <false/>
    <key>Label</key>
    <string>myserver</string>
    <key>OnDemand</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
        <string>/opt/MYServer/MYServer</string>
        <string>-server</string>
        <string>-outfile</string>
        <string>/opt/MYServer/out.txt</string>
        <string>-errfile</string>
        <string>/opt/MYServer/err.txt</string>
        <string>-verbose</string>
        <string>-debug</string>
        <string>-nodetach</string>
        <string>-home</string>
        <string>/System/Library/Frameworks/JavaVM.framework/Home</string>
        <string>-cp</string>
        <string>/opt/MYServer/lib/hsqldb.jar:/opt/MYServer/lib/my-wrapper.jar:/opt/MYServer/lib/commons-daemon-1.0.8.jar</string>
        <string>my.service.DaemonMac</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/opt/MYServer/stderr.log</string>
    <key>StandardOutPath</key>
    <string>/opt/MYServer/stdout.log</string>
    <key>WorkingDirectory</key>
    <string>/opt/MYServer</string>
</dict>
</plist>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM