Seshadri R
Seshadri R

Reputation: 1212

Jupyterhub does not run through plist

I have been running jupyterhub 0.91. in a MacOS Sierra (Version 10.12.6) successfully and could access the notebook from any client connected to this MacOS network. I attempted to make jupyterhub as a service. Towards this, I created the org.xyz.jupyter.plist file in /Users/xyz/Library/LaunchAgents (xyz is my user ID) with the following contents (standard header and footer info omitted for brevity):

<dict>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>org.xyz.jupyter</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/xyz/Library/LaunchAgents/jupyterhub.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/Users/Shared/jupyterhub.err</string>
    <key>StandardOutPath</key>
    <string>/Users/Shared/jupyterhub.out</string>
    <key>KeepAlive</key>
    <true/>
</dict>

And, the contents of /Users/xyz/Library/LaunchAgents/jupyterhub.sh are:

PID=$(pgrep -f jupyterhub)
if [ "x$PID" = "x" ]; then # Ensure only one jupyterhub instance is running
    sudo /opt/anaconda/anaconda3/bin/jupyterhub -f /Users/Shared/jupyterhub_config.py
fi

I ran the above shell script independently and jupyterhub started without posing any problems. However, when I restarted my Mac to auto start the hub, I got the following error (excerpts):

  File "/opt/anaconda/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'configurable-http-proxy': 'configurable-http-proxy'

I checked the location /opt/anaconda/anaconda3/bin/ from where jupyterhub is executed and found the file configurable-http-proxy. Then, I copied it to: /opt/anaconda/anaconda3/lib/python3.6 from where the subprocess.py is executing and reporting the absence of configurable-http-proxy. Still, the error remains the same. Any help, please?

Upvotes: 1

Views: 146

Answers (1)

Seshadri R
Seshadri R

Reputation: 1212

When the agent to start jupyterhub is run, it does not seem to have any idea about the executables' locations. In this case, it does not know where configurable-http-proxy is resident. So, I added an EnvironmentVariables directive that contains the path (/opt/anaconda/anaconda3/bin) for the above file. The revised plist file is:

<dict>
    <key>EnvironmentVariables</key>
    <dict>
      <key>PATH</key>
      <string>/opt/anaconda/anaconda3/bin:/bin:/usr/bin</string>
    </dict>
    <key>Label</key>
    <string>org.xyz.jupyter</string>
    <key>ProgramArguments</key>
    <array>
        <string>/opt/anaconda/anaconda3/bin/jupyterhub</string>
        <string>-f</string>
        <string>/Users/Shared/jupyterhub_config.py</string>
    </array>

Rest of things as shown in my question.

Upvotes: 2

Related Questions