docker fixes
This commit is contained in:
parent
213adcaaaa
commit
7ab789f80a
8 changed files with 37 additions and 38 deletions
7
ctl
7
ctl
|
@ -17,7 +17,7 @@ if [ "$action" = "init" ]; then
|
||||||
SUDO=""
|
SUDO=""
|
||||||
PANDORA_USER=`ls -l update.py | cut -f3 -d" "`
|
PANDORA_USER=`ls -l update.py | cut -f3 -d" "`
|
||||||
if [ `whoami` != $PANDORA_USER ]; then
|
if [ `whoami` != $PANDORA_USER ]; then
|
||||||
SUDO="sudo -H -u $PANDORA_USER"
|
SUDO="sudo -E -H -u $PANDORA_USER"
|
||||||
fi
|
fi
|
||||||
$SUDO python3 -m venv --system-site-packages .
|
$SUDO python3 -m venv --system-site-packages .
|
||||||
branch=`cat .git/HEAD | sed 's@/@\n@g' | tail -n1`
|
branch=`cat .git/HEAD | sed 's@/@\n@g' | tail -n1`
|
||||||
|
@ -62,11 +62,10 @@ if [ ! -z $cmd ]; then
|
||||||
SUDO=""
|
SUDO=""
|
||||||
PANDORA_USER=`ls -l update.py | cut -f3 -d" "`
|
PANDORA_USER=`ls -l update.py | cut -f3 -d" "`
|
||||||
if [ `whoami` != $PANDORA_USER ]; then
|
if [ `whoami` != $PANDORA_USER ]; then
|
||||||
SUDO="sudo -H -u $PANDORA_USER"
|
SUDO="sudo -E -H -u $PANDORA_USER"
|
||||||
fi
|
fi
|
||||||
shift
|
shift
|
||||||
$SUDO "$BASE/$cmd" $@
|
exec $SUDO "$BASE/$cmd" $@
|
||||||
exit $?
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ `whoami` != 'root' ]; then
|
if [ `whoami` != 'root' ]; then
|
||||||
|
|
|
@ -30,6 +30,7 @@ apt-get update -qq
|
||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
netcat-openbsd \
|
netcat-openbsd \
|
||||||
sudo \
|
sudo \
|
||||||
|
rsync \
|
||||||
iproute2 \
|
iproute2 \
|
||||||
vim \
|
vim \
|
||||||
wget \
|
wget \
|
||||||
|
|
|
@ -8,6 +8,8 @@ export LANG=en_US.UTF-8
|
||||||
mkdir -p /run/pandora
|
mkdir -p /run/pandora
|
||||||
chown -R ${user}.${user} /run/pandora
|
chown -R ${user}.${user} /run/pandora
|
||||||
|
|
||||||
|
update="/usr/bin/sudo -u $user -E -H /srv/pandora/update.py"
|
||||||
|
|
||||||
# pan.do/ra services
|
# pan.do/ra services
|
||||||
if [ "$action" = "pandora" ]; then
|
if [ "$action" = "pandora" ]; then
|
||||||
if [ ! -e /srv/pandora/initialized ]; then
|
if [ ! -e /srv/pandora/initialized ]; then
|
||||||
|
@ -26,12 +28,12 @@ if [ "$action" = "pandora" ]; then
|
||||||
/overlay/install.py
|
/overlay/install.py
|
||||||
|
|
||||||
echo "Initializing database..."
|
echo "Initializing database..."
|
||||||
echo "CREATE EXTENSION pg_trgm;" | /srv/pandora/pandora/manage.py dbshell
|
echo "CREATE EXTENSION pg_trgm;" | /srv/pandora/pandora/manage.py dbshell || true
|
||||||
/srv/pandora/pandora/manage.py init_db
|
/srv/pandora/pandora/manage.py init_db
|
||||||
/srv/pandora/update.py db
|
$update db
|
||||||
echo "Generating static files..."
|
echo "Generating static files..."
|
||||||
/srv/pandora/update.py static
|
|
||||||
chown -R ${user}.${user} /srv/pandora/
|
chown -R ${user}.${user} /srv/pandora/
|
||||||
|
$update static
|
||||||
touch /srv/pandora/initialized
|
touch /srv/pandora/initialized
|
||||||
fi
|
fi
|
||||||
/srv/pandora_base/docker/wait-for db 5432
|
/srv/pandora_base/docker/wait-for db 5432
|
||||||
|
@ -44,54 +46,53 @@ if [ "$action" = "encoding" ]; then
|
||||||
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
|
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
|
||||||
/srv/pandora_base/docker/wait-for rabbitmq 5672
|
/srv/pandora_base/docker/wait-for rabbitmq 5672
|
||||||
name=pandora-encoding-$(hostname)
|
name=pandora-encoding-$(hostname)
|
||||||
|
cd /srv/pandora/pandora
|
||||||
exec /usr/bin/sudo -u $user -E -H \
|
exec /usr/bin/sudo -u $user -E -H \
|
||||||
/srv/pandora/bin/python \
|
/srv/pandora/bin/celery \
|
||||||
/srv/pandora/pandora/manage.py \
|
-A app worker \
|
||||||
celery worker \
|
-Q encoding -n ${name} \
|
||||||
-c 1 \
|
--pidfile /run/pandora/encoding.pid \
|
||||||
-Q encoding -n $name \
|
--maxtasksperchild 500 \
|
||||||
-l INFO
|
-c 1 \
|
||||||
|
-l INFO
|
||||||
fi
|
fi
|
||||||
if [ "$action" = "tasks" ]; then
|
if [ "$action" = "tasks" ]; then
|
||||||
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
|
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
|
||||||
/srv/pandora_base/docker/wait-for rabbitmq 5672
|
/srv/pandora_base/docker/wait-for rabbitmq 5672
|
||||||
name=pandora-default-$(hostname)
|
name=pandora-default-$(hostname)
|
||||||
|
cd /srv/pandora/pandora
|
||||||
exec /usr/bin/sudo -u $user -E -H \
|
exec /usr/bin/sudo -u $user -E -H \
|
||||||
/srv/pandora/bin/python \
|
/srv/pandora/bin/celery \
|
||||||
/srv/pandora/pandora/manage.py \
|
-A app worker \
|
||||||
celery worker \
|
-Q default,celery -n ${name} \
|
||||||
-Q default,celery -n $name \
|
--pidfile /run/pandora/tasks.pid \
|
||||||
--maxtasksperchild 1000 \
|
--maxtasksperchild 1000 \
|
||||||
-l INFO
|
-l INFO
|
||||||
fi
|
fi
|
||||||
if [ "$action" = "cron" ]; then
|
if [ "$action" = "cron" ]; then
|
||||||
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
|
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
|
||||||
/srv/pandora_base/docker/wait-for rabbitmq 5672
|
/srv/pandora_base/docker/wait-for rabbitmq 5672
|
||||||
|
cd /srv/pandora/pandora
|
||||||
exec /usr/bin/sudo -u $user -E -H \
|
exec /usr/bin/sudo -u $user -E -H \
|
||||||
/srv/pandora/bin/python \
|
/srv/pandora/bin/celery \
|
||||||
/srv/pandora/pandora/manage.py \
|
-A app beat \
|
||||||
celerybeat -s /run/pandora/celerybeat-schedule \
|
-s /run/pandora/celerybeat-schedule \
|
||||||
--pidfile /run/pandora/cron.pid \
|
--pidfile /run/pandora/cron.pid \
|
||||||
-l INFO
|
-l INFO
|
||||||
fi
|
fi
|
||||||
if [ "$action" = "websocketd" ]; then
|
if [ "$action" = "websocketd" ]; then
|
||||||
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
|
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
|
||||||
/srv/pandora_base/docker/wait-for rabbitmq 5672
|
/srv/pandora_base/docker/wait-for rabbitmq 5672
|
||||||
|
cd /srv/pandora/pandora
|
||||||
exec /usr/bin/sudo -u $user -E -H \
|
exec /usr/bin/sudo -u $user -E -H \
|
||||||
/srv/pandora/bin/python \
|
/srv/pandora/bin/python \
|
||||||
/srv/pandora/pandora/manage.py websocketd
|
/srv/pandora/pandora/manage.py websocketd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# pan.do/ra management and update
|
# pan.do/ra management and update
|
||||||
if [ "$action" = "manage.py" ]; then
|
if [ "$action" = "ctl" ]; then
|
||||||
shift
|
shift
|
||||||
exec /usr/bin/sudo -u $user -E -H \
|
exec /srv/pandora/ctl "$@"
|
||||||
/srv/pandora/pandora/manage.py "$@"
|
|
||||||
fi
|
|
||||||
if [ "$action" = "update.py" ]; then
|
|
||||||
shift
|
|
||||||
exec /usr/bin/sudo -u $user -E -H \
|
|
||||||
/srv/pandora/update.py "$@"
|
|
||||||
fi
|
fi
|
||||||
if [ "$action" = "bash" ]; then
|
if [ "$action" = "bash" ]; then
|
||||||
shift
|
shift
|
||||||
|
|
|
@ -56,13 +56,9 @@ cp /srv/pandora/docker/entrypoint.sh /entrypoint.sh
|
||||||
mv /srv/pandora/ /srv/pandora_base/
|
mv /srv/pandora/ /srv/pandora_base/
|
||||||
mkdir /pandora
|
mkdir /pandora
|
||||||
ln -s /pandora /srv/pandora
|
ln -s /pandora /srv/pandora
|
||||||
cat > /usr/local/bin/update.py << EOF
|
|
||||||
#!/bin/sh
|
|
||||||
exec /srv/pandora/update.py \$@
|
|
||||||
EOF
|
|
||||||
|
|
||||||
cat > /usr/local/bin/manage.py << EOF
|
cat > /usr/local/bin/pandoractl << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec /srv/pandora/pandora/manage.py \$@
|
exec /srv/pandora/ctl \$@
|
||||||
EOF
|
EOF
|
||||||
chmod +x /usr/local/bin/manage.py /usr/local/bin/update.py
|
chmod +x /usr/local/bin/pandoractl
|
||||||
|
|
|
@ -26,7 +26,7 @@ and to get started run this:
|
||||||
|
|
||||||
To update pan.do/ra run:
|
To update pan.do/ra run:
|
||||||
|
|
||||||
docker-compose run pandora update.py
|
docker-compose run pandora ctl update
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
touch __init__.py
|
touch __init__.py
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
TIMEOUT=60
|
TIMEOUT=180
|
||||||
TARGET="$1"
|
TARGET="$1"
|
||||||
|
|
||||||
for i in `seq $TIMEOUT` ; do
|
for i in `seq $TIMEOUT` ; do
|
||||||
|
|
|
@ -11,6 +11,8 @@ def run(cmd):
|
||||||
stdout, stderr = p.communicate()
|
stdout, stderr = p.communicate()
|
||||||
|
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
|
print('failed to run:', cmd)
|
||||||
|
print(stdout)
|
||||||
print(stderr)
|
print(stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ def get_location(ip):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
location = g.city(ip)
|
location = g.city(ip)
|
||||||
except GeoIP2Exception:
|
except:
|
||||||
try:
|
try:
|
||||||
location = g.country(s.ip)
|
location = g.country(s.ip)
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in a new issue