peers / peerjs-server

Server for PeerJS

Home Page:https://peerjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running peer server with macOS launchctl / lauchDaemon

newmediacrew opened this issue · comments

Give an expressive description of what is went wrong
Running peer server with macOS launchctl / lauchDaemon in a plist file doesn't work.

Version of peer you're experiencing this issue
0.6.1

Nodejs version?
v16.13.2

Platform name and its version (Win, Mac, Linux)?
macOS Monterey 12.1

The problem
Running peerjs --port 2087 --expire_timeout 60000 --alive_timeout 60000 --path / --sslcert /usr/local/etc/ssl/local.dev.pem --sslkey /usr/local/etc/ssl/local.dev.pem from the commandline works perferctly.

We want to use the lauchDaemon to start the peer server every time our Mac starts by creating a plist file in the /Library/LaunchDaemon folder.

Content of the plist file
https://pastebin.com/DXjmtggL

Log
2022-01-21 20:43:39.951961 (system/ctbChattabaiPeerServer) : internal event: WILL_SPAWN, code = 0
2022-01-21 20:43:39.951982 (system/ctbChattabaiPeerServer) : service state: spawn scheduled
2022-01-21 20:43:39.951983 (system/ctbChattabaiPeerServer) : service state: spawning
2022-01-21 20:43:39.952057 (system/ctbChattabaiPeerServer) : launching: speculative
2022-01-21 20:43:39.952434 (system/ctbChattabaiPeerServer [1879]) : xpcproxy spawned with pid 1879
2022-01-21 20:43:39.952449 (system/ctbChattabaiPeerServer [1879]) : internal event: SPAWNED, code = 0
2022-01-21 20:43:39.952451 (system/ctbChattabaiPeerServer [1879]) : service state: xpcproxy
2022-01-21 20:43:39.952511 (system) : Bootstrap by launchctl[1878] for /Library/LaunchDaemons/ctbChattabaiPeerServer.plist succeeded (0: )
2022-01-21 20:43:39.952549 (system/ctbChattabaiPeerServer [1879]) : internal event: SOURCE_ATTACH, code = 0
2022-01-21 20:43:39.954660 (system/ctbChattabaiPeerServer [1879]) : service state: running
2022-01-21 20:43:39.954678 (system/ctbChattabaiPeerServer [1879]) : internal event: INIT, code = 0
2022-01-21 20:43:39.954686 (system/ctbChattabaiPeerServer [1879]) : Successfully spawned peerjs[1879] because speculative
2022-01-21 20:43:39.956184 (system/ctbChattabaiPeerServer [1879]) : service exited: dirty = 0, supported pressured-exit = 0
2022-01-21 20:43:39.956208 (system/ctbChattabaiPeerServer [1879]) : exited due to exit(127)
2022-01-21 20:43:39.956211 (system/ctbChattabaiPeerServer [1879]) : service state: exited
2022-01-21 20:43:39.956214 (system/ctbChattabaiPeerServer [1879]) : internal event: EXITED, code = 0
2022-01-21 20:43:39.956217 (system) : service inactive: ctbChattabaiPeerServer
2022-01-21 20:43:39.956221 (system/ctbChattabaiPeerServer [1879]) : service state: not running

Anyone got any ideas

Not an expert on launchctl, but you could try splitting the argument. So

<string>--port</string>
<string>2087</string>
<string>--expire_timeout</string>
<string>60000</string>
<string>--alive_timeout</string>
<string>60000</string>
<string>--path</string>
<string>/</string>
<string>--sslcert</string>
<string>/usr/local/etc/ssl/local.dev.pem</string>
<string>--sslkey</string>
<string>/usr/local/etc/ssl/local.dev.pem</string>

instead of

<string>--port 2087 --expire_timeout 60000 --alive_timeout 60000 --path / --sslcert /usr/local/etc/ssl/local.dev.pem --sslkey /usr/local/etc/ssl/local.dev.pem </string>

Please tell me if it works @newmediacrew.

Hello, this might be a late response. But for people that are also having this problem. Here is the solution. When you install the peer server, a symbolic link is created. Make sure you run the actual peerjs file itself and not the symbolic link. Here is a working example, @jonasgloning, used your bit of code to make everything more readable.

<?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>ctbChattabaiPeerServer</string>
        <key>ProgramArguments</key>
        <array>
                <string>/opt/homebrew/opt/node@16/bin/node</string>
                <string>/opt/homebrew/lib/node_modules/peer/bin/peerjs</string>
                <string>--port</string>
                <string>2087</string>
                <string>--expire_timeout</string>
                <string>60000</string>
                <string>--alive_timeout</string>
                <string>60000</string>
                <string>--path</string>
                <string>/</string>
                <string>--sslcert</string>
                <string>/opt/homebrew/etc/ssl/local.dev.crt</string>
                <string>--sslkey</string>
                <string>/opt/homebrew/etc/ssl/local.dev.key</string>
        </array>
        <key>RunAtLoad</key>
        <true/>
</dict>
</plist>
commented

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.