You'll want to create a launchd service on macOS. Here's how:

Step 1: Create the plist file

nano ~/Library/LaunchAgents/com.coder.code-server.plist

Step 2: Add this content:

<?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>com.coder.code-server</string>
    <key>ProgramArguments</key>
    <array>
        <string>/opt/homebrew/bin/code-server</string>
        <string>--bind-addr</string>
        <string>0.0.0.0:8080</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/tmp/code-server.log</string>
    <key>StandardErrorPath</key>
    <string>/tmp/code-server.err</string>
</dict>
</plist>

Step 3: Load the service

launchctl load ~/Library/LaunchAgents/com.coder.code-server.plist

Useful commands:

# Stop the service
launchctl unload ~/Library/LaunchAgents/com.coder.code-server.plist

# Restart it
launchctl unload ~/Library/LaunchAgents/com.coder.code-server.plist
launchctl load ~/Library/LaunchAgents/com.coder.code-server.plist

# Check if it's running
launchctl list | grep code-server

# View logs
tail -f /tmp/code-server.log
tail -f /tmp/code-server.err

Note: If you installed code-server via Homebrew on an Intel Mac, the path might be /usr/local/bin/code-server instead of /opt/homebrew/bin/code-server. You can verify with which code-server.