jupyterhub on the virtual environment startup settings

To make jupyterhub boot, or as a service starts, toss for a long time.
surroundings

16.04 Ubuntu
Anaconda> = 4.5
python35
jupyterhub 0.9.4
the Node 6.14.4
background
jupyterhub installed in the virtual environment conda only enter the virtual environment to execute jupyterhub command
script created can start jupyterhub
#! / bin / bash the -l
conda of an activate python35
cd / etc / jupyterhub
jupyterhub -f /etc/jupyterhub/jupyterhub_config.py >> /etc/jupyterhub/jupyter.log
bash sure to add -l purpose is to log the login shell, or the system may not recognize conda command, because the version of conda4.4 configuration commands into the /etc/profile.d/conda.sh, only the login shell login time will execute the file, the system will recognize conda command. You might compare wondering why use conda activate without source activate this does not work, because we want to put the boot startup item or service item, these two methods to identify the source of a source linux system, is used the command to update the status of the file, usually we change the system configuration files such as / etc / profile /etc/bash.bashrc updated with the source command, so bash will be identified as the source file update when the boot or start the service command , resulting in an error

Issues
need ./name.sh or bash name.sh when the above script every time you start to perform, and when we turn off the command line jupyterhub own service also will turn off, that is no way to run in the background.
Solutions
to the above script file as a boot entry, let it boot from (only restart the machine to take effect)
the above script as a service (similar to ssh server), such as through service or systemctl service management command and control (does not have to restart the machine, flexible, controllable)
was added to the boot entry in
reference to the principle of linking more detailed script is no problem as long as the links, you can perform, but the problem is the script if there is a problem, the service will not be started, and we do not know where mistakes. For example, we do not know the order in which the script is executed before or after the execution load the user profile, if the configuration is executed before the PATH and other user configuration, then some of the commands that the user will not be able to perform such conda, node configurable-http-proxy these three commands and jupyterhub relevant, if we write a script to perform before loading user profile, certainly does not work, so we try not to use this method

Services wrote in
our machines can be ubuntu 16.04 in systemctl management services

Create a file called jupyterhub.service in the / etc / systemd / system / services under the profile name jupyterhub suffix is .service, the name can easily own name, the name is later used systemctl configuration service name or service
in jupyterhub. write the following document service command
#-the start the Default: 2. 5. 4. 3
# the Stop-the Default: 0. 6. 1
[Unit]
the Description = jupyterhub (just a name)
the After syslog.target network.target = (network service starts after starting the script)
[service]
the User = root
ExecStart = / etc / jupyterhub / jupyterhub.sh (script address)
[the Install]
WantedBy = default.target
above configuration is the simplest system service configuration file to change the wording of what can be .

Systemctl start jupyterhub executed in a terminal to start the service
to view the service running state systemctl status jupyterhub
usually be wrong
if prompted node configurable-http-proxy error, can not find the file, and so on, and that reason is the priority of service before the system configuration, that is, node configuration of the PATH we have not been identified, so I ultimately the PATH node configuration into the / etc / profile success, and before put /etc/bash.bashrc and does not recognize the
service can start successfully executed systemctl enable jupyterhub allowing the boot from the start
that 'walked the pit, and I hope everyone in the same environment can avoid these pits.
----------------
Disclaimer: This article is CSDN blogger "quack pig" in the original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source and link this statement.
Original link: https: //blog.csdn.net/luoluonuoyasuolong/article/details/88815887

Guess you like

Origin www.cnblogs.com/adolfmc/p/11980161.html