Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add packaging support for 16.04 (and remove gunicorn) #1127

Merged
merged 2 commits into from
Sep 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 0 additions & 27 deletions digits-server

This file was deleted.

2 changes: 1 addition & 1 deletion digits/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


def main():
parser = argparse.ArgumentParser(description='DIGITS development server')
parser = argparse.ArgumentParser(description='DIGITS server')
parser.add_argument('-p', '--port',
type=int,
default=5000,
Expand Down
19 changes: 0 additions & 19 deletions digits/gunicorn_config.py

This file was deleted.

2 changes: 1 addition & 1 deletion digits/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def start_this_job(job):

def sigterm_handler(self, signal, frame):
"""
Gunicorn shuts down workers with SIGTERM, not SIGKILL
Catch SIGTERM in addition to SIGINT
"""
self.shutdown.set()

Expand Down
20 changes: 3 additions & 17 deletions docs/BuildDigits.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Doing so is your own adventure.

Install some dependencies with Deb packages:
```sh
sudo apt-get install --no-install-recommends git graphviz gunicorn python-dev python-flask python-flaskext.wtf python-gevent python-h5py python-numpy python-pil python-protobuf python-scipy
sudo apt-get install --no-install-recommends git graphviz python-dev python-flask python-flaskext.wtf python-gevent python-h5py python-numpy python-pil python-protobuf python-scipy
```

Follow [these instructions](BuildCaffe.md) to build Caffe (**required**).
Expand Down Expand Up @@ -44,20 +44,16 @@ sudo pip install -r $DIGITS_ROOT/requirements.txt

DIGITS needs to be installed to enable loading data and visualization plug-ins:
```
sudo pip install -e $DIGITS_HOME
sudo pip install -e $DIGITS_ROOT
```

# Starting the server

You can run DIGITS in two modes:

### Development mode

```sh
./digits-devserver
```

Starts a development server (werkzeug backend) at `http://localhost:5000/`.
Starts a server at `http://localhost:5000/`.
```
$ ./digits-devserver --help
usage: __main__.py [-h] [-p PORT] [-d] [--version]
Expand All @@ -72,16 +68,6 @@ optional arguments:
--version Print the version number and exit
```

### Production mode

```sh
./digits-server
```

Starts a production server (gunicorn backend) at `http://localhost:34448`.

If you have installed the nginx.site to `/etc/nginx/sites-enabled/`, then you can view your app at `http://localhost/`.

# Getting started

Now that you're up and running, check out the [Getting Started Guide](GettingStarted.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ See [Standard Datasets](StandardDatasets.md) for details about this script.
## Using the Webapp

Open up a web browser and navigate to the home screen of DIGITS.
The server should be at either `http://localhost/` (if installed from Deb packages), `http://localhost:5000/` (if using `digits-devserver`) or `http://localhost:34448/` (if using `digits-server`).
The server should be at either `http://localhost/` (if installed from Deb packages), or `http://localhost:5000/` (if using `digits-devserver`).

![Home page](images/home-page-1.jpg)

Expand Down
2 changes: 1 addition & 1 deletion packaging/deb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN apt-get update \
lintian \
&& rm -rf /var/lib/apt/lists/*

ENV DEBFULLNAME "DIGITS Development Team"
ENV DEBFULLNAME "NVIDIA CORPORATION"
ENV DEBEMAIL "digits@nvidia.com"
ENV DEB_BUILD_OPTIONS nocheck

Expand Down
78 changes: 54 additions & 24 deletions packaging/deb/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
set -e

LOCAL_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
DIGITS_ROOT=$(dirname "$(dirname "$LOCAL_DIR")")
cd $DIGITS_ROOT
TARBALL_DIR="${LOCAL_DIR}/tarball/"
SRC_DIR=$(dirname "$(dirname "$LOCAL_DIR")")
cd $SRC_DIR

################################################################################
### Check for basic requirements
################################################################################

if ! which git >/dev/null 2>&1; then
echo "git not installed"
Expand All @@ -14,8 +17,8 @@ if ! git rev-parse >/dev/null 2>&1; then
echo "not a git repository"
exit 1
fi
if [ "$(git rev-parse --show-toplevel)" != "$DIGITS_ROOT" ]; then
echo "$DIGITS_ROOT is not a git repository"
if [ "$(git rev-parse --show-toplevel)" != "$SRC_DIR" ]; then
echo "$SRC_DIR is not a git repository"
exit 1
fi
if ! which python >/dev/null 2>&1; then
Expand All @@ -26,41 +29,68 @@ if ! git diff-index --quiet HEAD >/dev/null 2>&1; then
echo "git index is dirty - either stash or commit your changes"
exit 1
fi
MODULE_VERSION=$(python -c "execfile('${DIGITS_ROOT}/digits/version.py'); print __version__")
if ! which docker >/dev/null 2>&1; then
echo "docker not installed"
exit 1
fi

################################################################################
# Read envvars
################################################################################

if [ -z "$DEBIAN_REVISION" ]; then
echo ">>> Using default DEBIAN_REVISION (set the envvar to override)"
DEBIAN_REVISION=1
fi
echo "DEBIAN_REVISION: $DEBIAN_REVISION"

################################################################################
# Calculate versions
################################################################################

MODULE_VERSION=$(python -c "execfile('${SRC_DIR}/digits/version.py'); print __version__")
echo MODULE_VERSION: $MODULE_VERSION
GIT_TAG=v${MODULE_VERSION}
if [ $(git tag -l $GIT_TAG | wc -l) -ne 1 ]; then
echo "$GIT_TAG is not a git tag"
exit 1
fi
DESCRIBE_VERSION=$(git describe --match $GIT_TAG)
SOURCE_VERSION=${DESCRIBE_VERSION:1}
UPSTREAM_VERSION=$(echo $SOURCE_VERSION | sed '0,/-/{s/-/~/}' | sed 's/-/\./g')
UPSTREAM_VERSION=${DESCRIBE_VERSION:1}
if [[ "$GIT_TAG" == *"-"* ]]; then
# Replace the first dash with a tilde
UPSTREAM_VERSION=$(echo $UPSTREAM_VERSION | sed '0,/-/{s/-/~/}')
fi
# Replace the first dash with a plus
UPSTREAM_VERSION=$(echo $UPSTREAM_VERSION | sed '0,/-/{s/-/\+/}')
# Replace all dashes with dots
UPSTREAM_VERSION=$(echo $UPSTREAM_VERSION | sed 's/-/\./g')
echo UPSTREAM_VERSION: $UPSTREAM_VERSION
DEBIAN_VERSION=${UPSTREAM_VERSION}-${DEBIAN_REVISION}
echo DEBIAN_VERSION: $DEBIAN_VERSION

################################################################################
# Create source tarball
################################################################################

TARBALL_DIR="${LOCAL_DIR}/tarball/"
rm -rf $TARBALL_DIR
mkdir -p $TARBALL_DIR
git archive --prefix "digits/" -o $TARBALL_DIR/digits_${UPSTREAM_VERSION}.orig.tar.gz HEAD
git archive --prefix "digits/" -o $TARBALL_DIR/digits.orig.tar.gz HEAD

DEBIAN_REVISION=${DEBIAN_REVISION:-1}
echo DEBIAN_REVISION: $DEBIAN_REVISION
DEBIAN_VERSION=${UPSTREAM_VERSION}-${DEBIAN_REVISION}
echo DEBIAN_VERSION: $DEBIAN_VERSION
################################################################################
# Build
################################################################################

if ! which docker >/dev/null 2>&1; then
echo "docker not installed"
exit 1
fi
DOCKER_ID="digits-debbuild"
cd $LOCAL_DIR
docker build -t $DOCKER_ID \
DOCKER_BUILD_ID="digits-debuild"
docker build -t $DOCKER_BUILD_ID \
--build-arg UPSTREAM_VERSION=$UPSTREAM_VERSION \
--build-arg DEBIAN_VERSION=$DEBIAN_VERSION \
.

docker ps -a -f "name=${DOCKER_ID}" -q | xargs -r docker rm
docker create --name=$DOCKER_ID $DOCKER_ID
docker ps -a -f "name=${DOCKER_BUILD_ID}" -q | xargs -r docker rm
docker create --name=$DOCKER_BUILD_ID $DOCKER_BUILD_ID
rm -rf dist/
docker cp $DOCKER_ID:/dist .
docker rm $DOCKER_ID
docker cp $DOCKER_BUILD_ID:/dist .
docker rm $DOCKER_BUILD_ID
find `pwd`/dist/ -type f | sort
6 changes: 3 additions & 3 deletions packaging/deb/extras/custom_http_errors/413.shtml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<title>File too large</title>
<title>Failed to upload file</title>
<body>
<h1>Error - File upload too large</h1>
<h1>Error: File upload too large</h1>
<p>
You attempted to upload a file that exceeded the limit allowed by the
NGINX reverse proxy server.
Expand All @@ -13,7 +13,7 @@ You can try uploading your file directly to the DIGITS server running at
</p>
<p>
You can also try increasing the value of the client_max_body_size setting
in /etc/nginx/sites-available/digits.site.
in /etc/nginx/sites-available/digits.nginx-site.
</p>
</body>
</html>
37 changes: 30 additions & 7 deletions packaging/deb/extras/custom_http_errors/502.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
<html>
<title>Failed to connect to DIGITS</title>
<body>
<h1>Error: Unable to connect to NVIDIA DIGITS</h1>
<h1>Error: Unable to connect to DIGITS</h1>

<h3>Restart the server</h3>
<p>
To fix this problem, try stopping and restarting the DIGITS server by running
the following two commands:
On Ubuntu 14.04, use this command to restart the server:
</p>
<pre>
sudo stop digits
sudo start digits
sudo service digits restart
</pre>
<p>
If you are still encountering problems after attempting to restart the DIGITS
server, check /var/log/digits/digits.log for errors.
On Ubuntu 16.04, use this command to restart the server:
</p>
<pre>
sudo systemctl restart digits
</pre>

<h3>Check the logs for errors</h3>
<p>
If you are still encountering problems after restarting, check the logs for errors.
</p>
<pre>
cat /var/log/digits/digits.log
</pre>
</p>
<p>
For additional messsages on Ubuntu 14.04:
</p>
<pre>
cat /var/log/upstart/digits.log
</pre>
<p>
For additional messages on Ubuntu 16.04:
</p>
<pre>
journalctl -u digits.service
</pre>
</body>
</html>
4 changes: 2 additions & 2 deletions packaging/deb/extras/digits.nginx-site
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# DIGITS nginx site
# DIGITS NGINX site

server {
listen 80; #AUTOCONFIG port (DO NOT DELETE THIS LINE)

# Gunicorn server
# Main server
location / {
client_max_body_size 500M; # Increase this if you receive error 413

Expand Down
3 changes: 1 addition & 2 deletions packaging/deb/templates/control
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ Maintainer: #USERNAME# <#EMAIL#>
Homepage: https://developer.nvidia.com/digits
Vcs-Browser: https://github.com/NVIDIA/DIGITS
Priority: optional
Build-Depends: debhelper (>= 9), dh-python, python-all, python-setuptools, debconf
Build-Depends: debhelper (>= 9), dh-python, dh-systemd, python-all, python-setuptools, debconf
Standards-Version: #POLICY#

Package: digits
Architecture: all
Depends: ${misc:Depends}, ${python:Depends},
caffe-nv (>= 0.13),
graphviz,
gunicorn,
nginx,
python-caffe-nv (>= 0.13),
python-flaskext.socketio (>= 2.6),
Expand Down
4 changes: 2 additions & 2 deletions packaging/deb/templates/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Upstream-Name: #PACKAGE#
Source: https://github.com/NVIDIA/DIGITS

Files: *
Copyright: #YEAR# #USERNAME# <#EMAIL#>
Copyright: #YEAR# NVIDIA CORPORATION
License: BSD-3-Clause

Files: debian/*
Copyright: #YEAR# #USERNAME# <#EMAIL#>
Copyright: #YEAR# NVIDIA CORPORATION
License: BSD-3-Clause

License: BSD-3-Clause
Expand Down
2 changes: 0 additions & 2 deletions packaging/deb/templates/digits.default

This file was deleted.

4 changes: 2 additions & 2 deletions packaging/deb/templates/digits.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ case "$1" in
# Update permissions on new directories
chown www-data /var/lib/digits/jobs /var/log/digits

# Disable default nginx site
# Disable default NGINX site
NGINX_NEEDS_RELOAD=false
DEFAULT_SITE=/etc/nginx/sites-enabled/default
if [ -L "$DEFAULT_SITE" ]
Expand All @@ -26,7 +26,7 @@ case "$1" in

# Enable nginx site
SITE_FILE=/etc/nginx/sites-available/digits.nginx-site
SITE_LINK=/etc/nginx/sites-enabled/digits.site
SITE_LINK=/etc/nginx/sites-enabled/digits.nginx-site
if [ "$PORT" != "-1" ]
then
sed "s/.*AUTOCONFIG port.*/ listen ${PORT}; #AUTOCONFIG port (DO NOT DELETE THIS LINE)/" $SITE_FILE -i
Expand Down
4 changes: 2 additions & 2 deletions packaging/deb/templates/digits.prerm
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ set -e

case "$1" in
remove)
# Disable nginx site
SITE_LINK=/etc/nginx/sites-enabled/digits.site
# Disable NGINX site
SITE_LINK=/etc/nginx/sites-enabled/digits-nginx.site
if [ -L "$SITE_LINK" ]
then
rm -f $SITE_LINK
Expand Down