jupyter-server-proxy icon indicating copy to clipboard operation
jupyter-server-proxy copied to clipboard

Support starting a server process on jupyter-server-proxy initialization

Open BobCashStory opened this issue 3 years ago • 9 comments

Proposed change

I would like to start a process when user start they machine . But for now the process start only when the user click on the launcher button, so can we have an autosatart option to start on machine boot ?

Or can the proxy allow to connect to already running app with the launcher entry present ?

Alternative options

Who would use this feature?

(Optional): Suggest a solution

BobCashStory avatar Sep 23 '20 10:09 BobCashStory

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

welcome[bot] avatar Sep 23 '20 10:09 welcome[bot]

For people who want the same, i did a hack :

install port forwarding module : apt-get install redir add to your jupyter_notebook_config.py

import os
os.system('python -m naas.runner -d') # Your process in detached mode

c.ServerProxy.servers = {
    'naas': {
        'launcher_entry': {
            'enabled': True,
            'icon_path': '/etc/jupyter/naas_logo.svg',
            'title': 'Naas manager',
        },
        'new_browser_tab': False,
        'timeout': 30,
        'command': ["redir", "--lport={port}", "--cport=5000"], # the redirect command to it !
    }
}

BobCashStory avatar Sep 23 '20 13:09 BobCashStory

Hi @BobCashStory , I think starting at boot is out of scope for jupyter-server-proxy, but you can always do this via the init system, e.g. a systemd unit file.

jupyter-server-proxy can already view an existing service however. For example you can visit /proxy/5000/. We don't have an elegant way to do this via a launcher however since we do require the command in the config.

ryanlovett avatar Sep 30 '20 17:09 ryanlovett

If you are working in a BinderHub environment, you can add startup items to the .binder/start file:

#!/bin/bash

nohup mycommand subcommand &

exec "$@"

psychemedia avatar Nov 05 '20 13:11 psychemedia

A user experience (UX) motivating autostarting processes

I'm installing syncthing which is like dropbox - syncing files/directories. A service like syncthing need to be started to do it's configured directory syncing, but it also needs to be accessed by users that initially configures what directories are to be synced etc.

jupyter-syncthing-proxy helps expose the syncthing UI to configure it, but also starts syncthing by doing so.

Currently, the jupyterhub where i install this just adds syncthing to be installed via conda-forge, and jupyter-syncthing-proxy via PyPI. I think another step would be relevant though - to ensure syncthing gets started so previously configured directory syncing can resume on startup without needing to press the launcher button.

Feature description

The feature as I think of it, would be to allow jupyter-server-proxy to automatically start a command ahead of the first request after having loaded its configuration. So I distinguish boot of the computer/container from having loaded of jupyter-server-proxy. I presume jupyter-server-proxy would start as part of a jupyter_server starts.

A benefit of not working around jupyter-server-proxy's inability to autostart on load would be that you wouldn't start two separate processes - one that jupyter-server-proxy wasn't aware of and one that it was aware of.


@ryanlovett what do you think about autostart as a feature on jupyter-server-proxy initialization rather than system boot?

consideRatio avatar Mar 08 '22 13:03 consideRatio

Another proxied service that might benefit from automated start-up is a notebook search engine that can be started when the server starts so that it can index notebooks as they are edited. I had an early POC here that IIRC had a horrible start up routine that blocked notebook server startup IIRC as it tried to index things before starting up the Jupyter server.

psychemedia avatar Mar 08 '22 22:03 psychemedia

@consideRatio That makes logical sense to me -- I have no objections. jupyter-server-proxy is both a web proxy and a process manager (via @yuvipanda's simpervisor), which sounds like an odd pairing, but it works since we're not trying to do much of the latter.

As an alternative, what if there was a jupyter-server extension that could run configurable hooks at server startup? In this case, it would issue a GET onto whatever proxied endpoint is desired, causing the corresponding process to start. If this is too decoupled from the jupyter-server-proxy configuration then maybe that's not desired or too messy. Just food for thought.

ryanlovett avatar Mar 09 '22 06:03 ryanlovett

My first thought is it sounds like a good idea, but I also think we should first scope out what it does, and what will/won't be supported in future to prevent maintenance becoming a burden.

  • Will the autostart be for web-services only (IIRC jupyter-server-proxy checks the process is alive by making a network request) or will non-network services also be supported (maybe you want to run some background tasks that don't require interaction?)
  • Is this something that should be in a separate component that jupyter-server-proxy builds on top of, e.g. so people can take advantage of process management without exposing any proxying URLs?

manics avatar Mar 09 '22 10:03 manics

What are the possible ways to start a process in jupyter server proxy other than the menu item click? Is it possible to run it programmatically from jupyter notebook? Or a restful endpoint that can be invoked from jupyter notebook Regards Ghansham

ghansham avatar Dec 02 '23 14:12 ghansham