Info

The silk hosting service is replacing the app server used for applications written with some programming languages. The following documentation is considered early-release and will be clarified over time.

Choosing a version of Python

You can choose among multiple versions of Python:

Silk platform Python version Command-line path
silkv1 2.6 /usr/bin/python
silkv1 2.7 (default) /usr/local/bin/python27
silkv2 2.7 (default) /usr/bin/python
silkv2 3.5 /usr/local/bin/python35
silkv2 3.6 /usr/local/bin/python36

If you need to switch Python versions, you can do so by creating or editing your site's .silk.ini file (for example ~/www-root/.silk.ini) and adding the version to the [python] section:

[python]
version = 3.6

Valid version choices are default, any of the versions listed in the table above, or newest (which provides the newest available on the system).

Web applications

Python web apps are written using the WSGI model and use NGINX Unit as an application server. You can run an application by doing the following:

  1. Edit the .silk.ini file in your site root. Add a section similar to the following.

    [app]
    type = python
    root = myapp
    document-root = public
    startup-script = wsgi.py

    The .silk.ini section name should be either "app" or any descriptive name you wish for your application that starts with "app: ". This could be useful if you wish to configure multiple apps.

    root is an optional directory under your site root containing all your application files.

    document-root is the directory under your app root in which static files will be located.

    startup-script is the name of the script launching your application, which should have executable permissions (chmod u+x wsgy.py).

  2. Notify SAA that you have made these changes, so that an app server can be configured for you and the web server can be set up to speak with it.

  3. Load your application with silk-app app load <hostname>. If you have multiple sites and/or multiple apps, <hostname> is followed by the URI path of your app, such as dev.mynetid.w3.uvm.edu/app2. If you see an error, check the app server log for details.

Reloading applications

An application needs to be restarted for code changes to take effect. You can do this the same way you originally loaded your application:

[myusername@silk21 ~]$ silk-app app load <hostname>

Console logs

App server logs are available at /usr/lib/unit-user-<mynetid>/unit.log.

Modules

Python modules are managed using the pip command.

You can see which modules are currently installed by typing pip list, or see which you have installed yourself with pip list --user.

Additional modules can be installed by typing pip install --user <modulename>, which will place them in your home directory, under ~/.local/. Scripts or commands included with a module are placed in ~/.local/bin/ and can either be run directly from there or added to your PATH by adding a line such as the following to ~/.bash_profile:

export PATH=~/.local/bin:$PATH