简体   繁体   中英

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. Found some manuals, wrote .plist file. 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:

<?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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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