From 49680fa16f7e21836bd5fe4ec766d123d985ca75 Mon Sep 17 00:00:00 2001 From: Taku Fukushima Date: Wed, 22 Jul 2015 13:04:47 +0900 Subject: [PATCH] Add a script to start Kuryr This patch adds scripts/run_server.py to launch Kuryr with Fask's development server. etc/kuryr.json is also introduced as the JSON spec file for the remote driver. scripts/run_kuryr.sh manages them and starts Kuryr appropriately as the following command: $ ./scripts/run_kuryr.sh Change-Id: Ie16a085dbf8fbb7dfdfaca009017ff7223cf1880 Signed-off-by: Taku Fukushima --- etc/kuryr.json | 4 ++++ scripts/run_kuryr.sh | 35 +++++++++++++++++++++++++++++++++++ scripts/run_server.py | 20 ++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 etc/kuryr.json create mode 100755 scripts/run_kuryr.sh create mode 100755 scripts/run_server.py diff --git a/etc/kuryr.json b/etc/kuryr.json new file mode 100644 index 00000000..f2fc2f53 --- /dev/null +++ b/etc/kuryr.json @@ -0,0 +1,4 @@ +{ + "Name": "kuryr", + "Addr": "http://127.0.0.1:2377" +} diff --git a/scripts/run_kuryr.sh b/scripts/run_kuryr.sh new file mode 100755 index 00000000..ab682cb1 --- /dev/null +++ b/scripts/run_kuryr.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +KURYR_HOME=${KURYR_HOME:-.} +KURYR_JSON_FILENAME=kuryr.json +KURYR_DEFAULT_JSON=${KURYR_HOME}/etc/${KURYR_JSON_FILENAME} +# See libnetwork's plugin discovery mechanism: +# https://github.com/docker/docker/blob/c4d45b6a29a91f2fb5d7a51ac36572f2a9b295c6/docs/extend/plugin_api.md#plugin-discovery +KURYR_JSON_DIR=${KURYR_JSON_DIR:-/usr/lib/docker/plugins/kuryr} +KURYR_JSON=${KURYR_JSON_DIR}/${KURYR_JSON_FILENAME} + +if [[ ! -d "${KURYR_JSON_DIR}" ]]; then + echo -n "${KURYR_JSON_DIR} directory is missing. Creating it... " + sudo mkdir -p ${KURYR_JSON_DIR} + echo "Done" +fi + +if [[ ! -f "${KURYR_JSON}" ]]; then + echo -n "${KURYR_JSON} is missing. Copyting the default one... " + sudo cp ${KURYR_DEFAULT_JSON} ${KURYR_JSON} + echo "Done" +fi + +PYTHONPATH=${KURYR_HOME} python ${KURYR_HOME}/scripts/run_server.py diff --git a/scripts/run_server.py b/scripts/run_server.py new file mode 100755 index 00000000..f1b1ed18 --- /dev/null +++ b/scripts/run_server.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from kuryr import app + + +if __name__ == '__main__': + app.debug = True + app.run("0.0.0.0", port=2377)