]> git.parisson.com Git - teleforma.git/commitdiff
rm wait-for-it, add hosts, update STATIC_ROOT
authorGuillaume Pellerin <guillaume.pellerin@parisson.com>
Sun, 4 Jun 2023 19:05:37 +0000 (21:05 +0200)
committerGuillaume Pellerin <guillaume.pellerin@parisson.com>
Sun, 4 Jun 2023 19:05:37 +0000 (21:05 +0200)
app/settings.py
app/wsgi.sh
bin/build/graph.sh
bin/build/messages.sh
bin/misc/wait-for-it/.gitignore [deleted file]
bin/misc/wait-for-it/.travis.yml [deleted file]
bin/misc/wait-for-it/LICENSE [deleted file]
bin/misc/wait-for-it/README.md [deleted file]
bin/misc/wait-for-it/test/wait-for-it.py [deleted file]
bin/misc/wait-for-it/wait-for-it.sh [deleted file]

index 05d147adc98218728d20a2aa8336000ccf124bfd..5ece2bd59799b592e0c1860305336187b1e4a7ac 100644 (file)
@@ -117,7 +117,7 @@ MEDIA_URL = 'http://localhost:8040/'
 # Don't put anything in this directory yourself; store your static files
 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
 # Example: "/home/media/media.lawrence.com/static/"
-STATIC_ROOT = '/var/www/static/'
+STATIC_ROOT = '/srv/static/'
 
 # URL prefix for static files.
 # Example: "http://media.lawrence.com/static/"
@@ -401,7 +401,13 @@ def show_user_as(user):
 POSTMAN_SHOW_USER_AS = show_user_as
 
 #THUMBNAIL_FORCE_OVERWRITE = True
-ALLOWED_HOSTS = ['localhost', 'ae.dockdev.pilotsystems.net', 'channels']
+ALLOWED_HOSTS = [
+    'localhost', 
+    'ae.dockdev.pilotsystems.net', 
+    'channels',
+    'staging.docker.e-learning.ae.pre-barreau.parisson.com',
+    'e-learning.ae.pre-barreau.com'
+]
 
 JAZZMIN_SETTINGS = {
     "site_title": "CRFPA",
index 43859828ee8bd9c3311a702747adca4fdf39e796..2eb50d5f8e4cb1428e3b6418c2d5e1067f3d2443 100755 (executable)
@@ -22,7 +22,7 @@ debug_log='/var/log/app/debug.log'
 # /srv/bin/build/local/setup_lib.sh
 
 # waiting for other services
-sh $app/wait.sh
+#sh $app/wait.sh
 
 # django setup
 #python $manage wait-for-db
@@ -43,7 +43,7 @@ else
 
     python $manage collectstatic --noinput
 
-    chown -R www-data: $debug_log
+    chown -R www-data: /var/log
 
     uwsgi /srv/app/wsgi.ini
 fi
index b5cda09ecc29d162bdb6e0be7ff5b2954dda8fb7..f2423137ebbfaf3ce34892bbd9688bc596d7a6ff 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-docker-compose run app python /srv/app/manage.py graph_models organization-core organization-media organization-pages organization.network organization.magazine organization.projects organization.agenda organization.shop organization.job > /srv/doc/graph/mezzanine-organization.dot
+docker-compose run app python /srv/app/manage.py graph_models organization_core organization-media organization_pages organization.network organization.magazine organization.projects organization.agenda organization.shop organization.job > /srv/doc/graph/mezzanine-organization.dot
index cea64eec8a414e6f158ae312002116e623b241d9..9a685c81963c6d6c66318364fbc293c54ef1fcf6 100755 (executable)
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-docker-compose run app bash /srv/bin/build/local/messages.sh
+docker compose exec app bash /srv/bin/build/local/messages.sh
diff --git a/bin/misc/wait-for-it/.gitignore b/bin/misc/wait-for-it/.gitignore
deleted file mode 100644 (file)
index 3e7e969..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-**/*.pyc
-.pydevproject
-
diff --git a/bin/misc/wait-for-it/.travis.yml b/bin/misc/wait-for-it/.travis.yml
deleted file mode 100644 (file)
index 30a8138..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-language: python
-python:
-  - "2.7"
-
-script:
-  - python test/wait-for-it.py
-
diff --git a/bin/misc/wait-for-it/LICENSE b/bin/misc/wait-for-it/LICENSE
deleted file mode 100644 (file)
index bd18d0c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-The MIT License (MIT)
-Copyright (c) 2016 Giles Hall
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is furnished to do
-so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/bin/misc/wait-for-it/README.md b/bin/misc/wait-for-it/README.md
deleted file mode 100644 (file)
index 4891736..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-## wait-for-it
-
-`wait-for-it.sh` is a pure bash script that will wait on the availability of a host and TCP port.  It is useful for synchronizing the spin-up of interdependent services, such as linked docker containers.  Since it is a pure bash script, it does not have any external dependencies.
-
-## Usage
-
-```
-wait-for-it.sh host:port [-s] [-t timeout] [-- command args]
--h HOST | --host=HOST       Host or IP under test
--p PORT | --port=PORT       TCP port under test
-                            Alternatively, you specify the host and port as host:port
--s | --strict               Only execute subcommand if the test succeeds
--q | --quiet                Don't output any status messages
--t TIMEOUT | --timeout=TIMEOUT
-                            Timeout in seconds, zero for no timeout
--- COMMAND ARGS             Execute command with args after the test finishes
-```
-
-## Examples
-
-For example, let's test to see if we can access port 80 on www.google.com, and if it is available, echo the message `google is up`.
-
-```
-$ ./wait-for-it.sh www.google.com:80 -- echo "google is up"
-wait-for-it.sh: waiting 15 seconds for www.google.com:80
-wait-for-it.sh: www.google.com:80 is available after 0 seconds
-google is up
-```
-
-You can set your own timeout with the `-t` or `--timeout=` option.  Setting the timeout value to 0 will disable the timeout:
-
-```
-$ ./wait-for-it.sh -t 0 www.google.com:80 -- echo "google is up"
-wait-for-it.sh: waiting for www.google.com:80 without a timeout
-wait-for-it.sh: www.google.com:80 is available after 0 seconds
-google is up
-```
-
-The subcommand will be executed regardless if the service is up or not.  If you wish to execute the subcommand only if the service is up, add the `--strict` argument. In this example, we will test port 81 on www.google.com which will fail:
-
-```
-$ ./wait-for-it.sh www.google.com:81 --timeout=1 --strict -- echo "google is up"
-wait-for-it.sh: waiting 1 seconds for www.google.com:81
-wait-for-it.sh: timeout occurred after waiting 1 seconds for www.google.com:81
-wait-for-it.sh: strict mode, refusing to execute subprocess
-```
-
-If you don't want to execute a subcommand, leave off the `--` argument.  This way, you can test the exit condition of `wait-for-it.sh` in your own scripts, and determine how to proceed:
-
-```
-$ ./wait-for-it.sh www.google.com:80
-wait-for-it.sh: waiting 15 seconds for www.google.com:80
-wait-for-it.sh: www.google.com:80 is available after 0 seconds
-$ echo $?
-0
-$ ./wait-for-it.sh www.google.com:81
-wait-for-it.sh: waiting 15 seconds for www.google.com:81
-wait-for-it.sh: timeout occurred after waiting 15 seconds for www.google.com:81
-$ echo $?
-124
-```
-
-## Community
-
-*Debian*: There is a [Debian package](https://tracker.debian.org/pkg/wait-for-it).
diff --git a/bin/misc/wait-for-it/test/wait-for-it.py b/bin/misc/wait-for-it/test/wait-for-it.py
deleted file mode 100644 (file)
index e06fb8c..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-import unittest
-import shlex
-from subprocess import Popen, PIPE
-import os
-import sys
-import socket
-import re
-
-MISSING_ARGS_TEXT = "Error: you need to provide a host and port to test."
-HELP_TEXT = "Usage:"  # Start of help text
-DIVIDE_LINE = '-'*71  # Output line of dashes
-
-
-class TestWaitForIt(unittest.TestCase):
-    """
-        TestWaitForIt tests the wait-for-it.sh shell script.
-        The wait-for-it.sh script is assumed to be in the parent directory to
-        the test script.
-    """
-
-    def execute(self, cmd):
-        """Executes a command and returns exit code, STDOUT, STDERR"""
-        args = shlex.split(cmd)
-        proc = Popen(args, stdout=PIPE, stderr=PIPE)
-        out, err = proc.communicate()
-        exitcode = proc.returncode
-        return exitcode, out, err
-
-    def open_local_port(self, host="localhost", port=8929, timeout=5):
-        s = socket.socket()
-        s.bind((host, port))
-        s.listen(timeout)
-        return s
-
-    def check_args(self, args, stdout_regex, stderr_regex, exitcode):
-        command = self.wait_script + " " + args
-        actual_exitcode, out, err = self.execute(command)
-
-        # Check stderr
-        msg = ("Failed check that STDERR:\n" +
-               DIVIDE_LINE + "\n" + err + "\n" + DIVIDE_LINE +
-               "\nmatches:\n" +
-               DIVIDE_LINE + "\n" + stderr_regex + "\n" + DIVIDE_LINE)
-        self.assertIsNotNone(re.match(stderr_regex, err, re.DOTALL), msg)
-
-        # Check STDOUT
-        msg = ("Failed check that STDOUT:\n" +
-               DIVIDE_LINE + "\n" + out + "\n" + DIVIDE_LINE +
-               "\nmatches:\n" +
-               DIVIDE_LINE + "\n" + stdout_regex + "\n" + DIVIDE_LINE)
-        self.assertIsNotNone(re.match(stdout_regex, out, re.DOTALL), msg)
-
-        # Check exit code
-        self.assertEqual(actual_exitcode, exitcode)
-
-    def setUp(self):
-        script_path = os.path.dirname(sys.argv[0])
-        parent_path = os.path.abspath(os.path.join(script_path, os.pardir))
-        self.wait_script = os.path.join(parent_path, "wait-for-it.sh")
-
-    def test_no_args(self):
-        """
-            Check that no aruments returns the missing args text and the
-            correct return code
-        """
-        self.check_args(
-            "",
-            "^$",
-            MISSING_ARGS_TEXT,
-            1
-        )
-        # Return code should be 1 when called with no args
-        exitcode, out, err = self.execute(self.wait_script)
-        self.assertEqual(exitcode,     1)
-
-    def test_help(self):
-        """ Check that help text is printed with --help argument """
-        self.check_args(
-           "--help",
-           "",
-           HELP_TEXT,
-           1
-        )
-
-    def test_no_port(self):
-        """ Check with missing port argument """
-        self.check_args(
-            "--host=localhost",
-            "",
-            MISSING_ARGS_TEXT,
-            1
-        )
-
-    def test_no_host(self):
-        """ Check with missing hostname argument """
-        self.check_args(
-            "--port=80",
-            "",
-            MISSING_ARGS_TEXT,
-            1
-        )
-
-    def test_host_port(self):
-        """ Check that --host and --port args work correctly """
-        soc = self.open_local_port(port=8929)
-        self.check_args(
-            "--host=localhost --port=8929 --timeout=1",
-            "",
-            "wait-for-it.sh: waiting 1 seconds for localhost:8929",
-            0
-        )
-        soc.close()
-
-    def test_combined_host_port(self):
-        """
-            Tests that wait-for-it.sh returns correctly after establishing a
-            connectionm using combined host and ports
-        """
-        soc = self.open_local_port(port=8929)
-        self.check_args(
-            "localhost:8929 --timeout=1",
-            "",
-            "wait-for-it.sh: waiting 1 seconds for localhost:8929",
-            0
-        )
-        soc.close()
-
-    def test_port_failure_with_timeout(self):
-        """
-            Note exit status of 124 is exected, passed from the timeout command
-        """
-        self.check_args(
-            "localhost:8929 --timeout=1",
-            "",
-            ".*timeout occurred after waiting 1 seconds for localhost:8929",
-            124
-        )
-
-    def test_command_execution(self):
-        """
-            Checks that a command executes correctly after a port test passes
-        """
-        soc = self.open_local_port(port=8929)
-        self.check_args(
-            "localhost:8929 -- echo \"CMD OUTPUT\"",
-            "CMD OUTPUT",
-            ".*wait-for-it.sh: localhost:8929 is available after 0 seconds",
-            0
-        )
-        soc.close()
-
-    def test_failed_command_execution(self):
-        """
-            Check command failure. The command in question outputs STDERR and
-            an exit code of 2
-        """
-        soc = self.open_local_port(port=8929)
-        self.check_args(
-            "localhost:8929 -- ls not_real_file",
-            "",
-            ".*No such file or directory\n",
-            2
-        )
-        soc.close()
-
-    def test_command_after_connection_failure(self):
-        """
-            Test that a command still runs even if a connection times out
-            and that the return code is correct for the comand being run
-        """
-        self.check_args(
-            "localhost:8929 --timeout=1 -- echo \"CMD OUTPUT\"",
-            "CMD OUTPUT",
-            ".*timeout occurred after waiting 1 seconds for localhost:8929",
-            0
-        )
-
-if __name__ == '__main__':
-    unittest.main()
diff --git a/bin/misc/wait-for-it/wait-for-it.sh b/bin/misc/wait-for-it/wait-for-it.sh
deleted file mode 100755 (executable)
index 071c2be..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-#!/usr/bin/env bash
-#   Use this script to test if a given TCP host/port are available
-
-WAITFORIT_cmdname=${0##*/}
-
-echoerr() { if [[ $WAITFORIT_QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
-
-usage()
-{
-    cat << USAGE >&2
-Usage:
-    $WAITFORIT_cmdname host:port [-s] [-t timeout] [-- command args]
-    -h HOST | --host=HOST       Host or IP under test
-    -p PORT | --port=PORT       TCP port under test
-                                Alternatively, you specify the host and port as host:port
-    -s | --strict               Only execute subcommand if the test succeeds
-    -q | --quiet                Don't output any status messages
-    -t TIMEOUT | --timeout=TIMEOUT
-                                Timeout in seconds, zero for no timeout
-    -- COMMAND ARGS             Execute command with args after the test finishes
-USAGE
-    exit 1
-}
-
-wait_for()
-{
-    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-        echoerr "$WAITFORIT_cmdname: waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-    else
-        echoerr "$WAITFORIT_cmdname: waiting for $WAITFORIT_HOST:$WAITFORIT_PORT without a timeout"
-    fi
-    WAITFORIT_start_ts=$(date +%s)
-    while :
-    do
-        if [[ $WAITFORIT_ISBUSY -eq 1 ]]; then
-            nc -z $WAITFORIT_HOST $WAITFORIT_PORT
-            WAITFORIT_result=$?
-        else
-            (echo > /dev/tcp/$WAITFORIT_HOST/$WAITFORIT_PORT) >/dev/null 2>&1
-            WAITFORIT_result=$?
-        fi
-        if [[ $WAITFORIT_result -eq 0 ]]; then
-            WAITFORIT_end_ts=$(date +%s)
-            echoerr "$WAITFORIT_cmdname: $WAITFORIT_HOST:$WAITFORIT_PORT is available after $((WAITFORIT_end_ts - WAITFORIT_start_ts)) seconds"
-            break
-        fi
-        sleep 1
-    done
-    return $WAITFORIT_result
-}
-
-wait_for_wrapper()
-{
-    # In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
-    if [[ $WAITFORIT_QUIET -eq 1 ]]; then
-        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --quiet --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-    else
-        timeout $WAITFORIT_BUSYTIMEFLAG $WAITFORIT_TIMEOUT $0 --child --host=$WAITFORIT_HOST --port=$WAITFORIT_PORT --timeout=$WAITFORIT_TIMEOUT &
-    fi
-    WAITFORIT_PID=$!
-    trap "kill -INT -$WAITFORIT_PID" INT
-    wait $WAITFORIT_PID
-    WAITFORIT_RESULT=$?
-    if [[ $WAITFORIT_RESULT -ne 0 ]]; then
-        echoerr "$WAITFORIT_cmdname: timeout occurred after waiting $WAITFORIT_TIMEOUT seconds for $WAITFORIT_HOST:$WAITFORIT_PORT"
-    fi
-    return $WAITFORIT_RESULT
-}
-
-# process arguments
-while [[ $# -gt 0 ]]
-do
-    case "$1" in
-        *:* )
-        WAITFORIT_hostport=(${1//:/ })
-        WAITFORIT_HOST=${WAITFORIT_hostport[0]}
-        WAITFORIT_PORT=${WAITFORIT_hostport[1]}
-        shift 1
-        ;;
-        --child)
-        WAITFORIT_CHILD=1
-        shift 1
-        ;;
-        -q | --quiet)
-        WAITFORIT_QUIET=1
-        shift 1
-        ;;
-        -s | --strict)
-        WAITFORIT_STRICT=1
-        shift 1
-        ;;
-        -h)
-        WAITFORIT_HOST="$2"
-        if [[ $WAITFORIT_HOST == "" ]]; then break; fi
-        shift 2
-        ;;
-        --host=*)
-        WAITFORIT_HOST="${1#*=}"
-        shift 1
-        ;;
-        -p)
-        WAITFORIT_PORT="$2"
-        if [[ $WAITFORIT_PORT == "" ]]; then break; fi
-        shift 2
-        ;;
-        --port=*)
-        WAITFORIT_PORT="${1#*=}"
-        shift 1
-        ;;
-        -t)
-        WAITFORIT_TIMEOUT="$2"
-        if [[ $WAITFORIT_TIMEOUT == "" ]]; then break; fi
-        shift 2
-        ;;
-        --timeout=*)
-        WAITFORIT_TIMEOUT="${1#*=}"
-        shift 1
-        ;;
-        --)
-        shift
-        WAITFORIT_CLI=("$@")
-        break
-        ;;
-        --help)
-        usage
-        ;;
-        *)
-        echoerr "Unknown argument: $1"
-        usage
-        ;;
-    esac
-done
-
-if [[ "$WAITFORIT_HOST" == "" || "$WAITFORIT_PORT" == "" ]]; then
-    echoerr "Error: you need to provide a host and port to test."
-    usage
-fi
-
-WAITFORIT_TIMEOUT=${WAITFORIT_TIMEOUT:-15}
-WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
-WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
-WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}
-
-# check to see if timeout is from busybox?
-WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
-WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)
-if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
-        WAITFORIT_ISBUSY=1
-        WAITFORIT_BUSYTIMEFLAG="-t"
-
-else
-        WAITFORIT_ISBUSY=0
-        WAITFORIT_BUSYTIMEFLAG=""
-fi
-
-if [[ $WAITFORIT_CHILD -gt 0 ]]; then
-    wait_for
-    WAITFORIT_RESULT=$?
-    exit $WAITFORIT_RESULT
-else
-    if [[ $WAITFORIT_TIMEOUT -gt 0 ]]; then
-        wait_for_wrapper
-        WAITFORIT_RESULT=$?
-    else
-        wait_for
-        WAITFORIT_RESULT=$?
-    fi
-fi
-
-if [[ $WAITFORIT_CLI != "" ]]; then
-    if [[ $WAITFORIT_RESULT -ne 0 && $WAITFORIT_STRICT -eq 1 ]]; then
-        echoerr "$WAITFORIT_cmdname: strict mode, refusing to execute subprocess"
-        exit $WAITFORIT_RESULT
-    fi
-    exec "${WAITFORIT_CLI[@]}"
-else
-    exit $WAITFORIT_RESULT
-fi