Project

General

Profile

Support #925

Install devpi on FreeBSD

Added by Daniel Curtis over 2 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Development
Target version:
Start date:
03/05/2018
Due date:
% Done:

100%

Estimated time:
1.00 h
Spent time:

Description

This is a guide on installing a devpi instance on FreeBSD 11-STABLE.

Prepare the Environment

  • Make sure the system is up to date:
    pkg update && pkg upgrade
    
  • Add devpi user:
    pw add user -n devpi -m -s /bin/sh -c "devpi" 
    
  • Install the dependencies using pkgng:
    pkg install python3 py36-{pip,setuptools}
    

Install devpi

  • Install devpi
    pip-3.6 install -q -U devpi-server
    
  • Initialize the devpi-server config:
    su - devpi -c 'devpi-server --init'
    
  • Test run the devpi server:
    su - devpi -c 'devpi-server --start --host 192.168.1.100'
    
  • Test download a python module:
    pip install --trusted-host 192.168.1.100 -i http://192.168.1.100:3141/root/pypi numpy
    
  • Stop the devpi-server:
    su - devpi -c 'devpi-server --stop'
    

init script

  • Create a folder for the pidfile:
    mkdir /var/run/devpi
    chown devpi /var/run/devpi
    
  • Create an init script for devpi notebook:
    vi /usr/local/etc/rc.d/devpi
    
    • And add the following:
      #!/bin/sh
      #
      # PROVIDE: devpi
      # REQUIRE: LOGIN
      #
      # Add the following lines to /etc/rc.conf to enable devpi notebook server
      #
      #
      # devpi_enable (bool): Set to "NO" by default,
      #                         Set it to "YES" to enable devpi notebook server
      
      . /etc/rc.subr
      
      name=devpi
      command=/usr/local/bin/devpi-server
      rcvar=devpi_enable
      
      load_rc_config $name
      
      devpi_enable="${devpi_enable-"NO"}" 
      devpi_user="${devpi_user-"devpi"}" 
      devpi_host="${devpi_host-"0.0.0.0"}" 
      devpi_pidfile="${devpi_pidfile:-"/var/run/devpi/devpi.pid"}"  
      
      # /etc/rc.subr use $pidfile (not ${name}_pidfile)
      pidfile="${devpi_pidfile}" 
      
      start_cmd="su - ${devpi_user} -c '${command} --start --host ${devpi_host}' &" 
      stop_cmd="${name}_stop" 
      status_cmd="${name}_status" 
      getval_cmd="${name}_getval" 
      
      devpi_stop()
      {
          devpi_pid=$(pgrep -f "devpi-server")
      
          echo "Stopping ${name}." 
          kill -s TERM "$(cat "${devpi_pidfile}")" 
      
          echo "Stopping ${name}." 
          kill -s TERM "${devpi_pid}" 
      
          rm ${devpi_pidfile}
      }
      
      devpi_status()
      {
          # Try its best to find the service's status
          if [ -f "${devpi_pidfile}" ]
          then
              devpi_pid="$(cat "${devpi_pidfile}")" 
          fi
      
          if [ -z "${devpi_pid}" ]
          then
          devpi_pid=$(pgrep -f "devpi-server")
          [ -n "${devpi_pid}" ] && echo "${devpi_pid}" > "${devpi_pidfile}" 
          fi
      
          if [ -n "${devpi_pid}" ]
          then
              echo "${name} running with pid: $devpi_pid" 
          else
              echo "${name} not running? (pid not found)" 
          fi
      }
      
      command_args=" >/dev/null 2>&1 &" 
      
      load_rc_config $name
      run_rc_command "$1" 
      
  • Make the script executable:
    chmod +x /usr/local/etc/rc.d/devpi
    
  • Start and enable devpi at boot:
    sysrc devpi_enable=YES
    service devpi start
    

Resources

History

#1 Updated by Daniel Curtis over 2 years ago

  • % Done changed from 0 to 100
  • Status changed from New to Resolved

#2 Updated by Daniel Curtis over 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF