Compare commits

..

No commits in common. "7ab789f80a48cd1dcfdeeaf04c1880e61b7f5945" and "fdac35c00db489d6e8c683a2ecfb790e226845e1" have entirely different histories.

9 changed files with 42 additions and 42 deletions

7
ctl
View file

@ -17,7 +17,7 @@ if [ "$action" = "init" ]; then
SUDO=""
PANDORA_USER=`ls -l update.py | cut -f3 -d" "`
if [ `whoami` != $PANDORA_USER ]; then
SUDO="sudo -E -H -u $PANDORA_USER"
SUDO="sudo -H -u $PANDORA_USER"
fi
$SUDO python3 -m venv --system-site-packages .
branch=`cat .git/HEAD | sed 's@/@\n@g' | tail -n1`
@ -62,10 +62,11 @@ if [ ! -z $cmd ]; then
SUDO=""
PANDORA_USER=`ls -l update.py | cut -f3 -d" "`
if [ `whoami` != $PANDORA_USER ]; then
SUDO="sudo -E -H -u $PANDORA_USER"
SUDO="sudo -H -u $PANDORA_USER"
fi
shift
exec $SUDO "$BASE/$cmd" $@
$SUDO "$BASE/$cmd" $@
exit $?
fi
if [ `whoami` != 'root' ]; then

View file

@ -30,7 +30,6 @@ apt-get update -qq
apt-get install -y \
netcat-openbsd \
sudo \
rsync \
iproute2 \
vim \
wget \

View file

@ -8,8 +8,6 @@ export LANG=en_US.UTF-8
mkdir -p /run/pandora
chown -R ${user}.${user} /run/pandora
update="/usr/bin/sudo -u $user -E -H /srv/pandora/update.py"
# pan.do/ra services
if [ "$action" = "pandora" ]; then
if [ ! -e /srv/pandora/initialized ]; then
@ -28,12 +26,12 @@ if [ "$action" = "pandora" ]; then
/overlay/install.py
echo "Initializing database..."
echo "CREATE EXTENSION pg_trgm;" | /srv/pandora/pandora/manage.py dbshell || true
echo "CREATE EXTENSION pg_trgm;" | /srv/pandora/pandora/manage.py dbshell
/srv/pandora/pandora/manage.py init_db
$update db
/srv/pandora/update.py db
echo "Generating static files..."
/srv/pandora/update.py static
chown -R ${user}.${user} /srv/pandora/
$update static
touch /srv/pandora/initialized
fi
/srv/pandora_base/docker/wait-for db 5432
@ -46,53 +44,54 @@ if [ "$action" = "encoding" ]; then
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
/srv/pandora_base/docker/wait-for rabbitmq 5672
name=pandora-encoding-$(hostname)
cd /srv/pandora/pandora
exec /usr/bin/sudo -u $user -E -H \
/srv/pandora/bin/celery \
-A app worker \
-Q encoding -n ${name} \
--pidfile /run/pandora/encoding.pid \
--maxtasksperchild 500 \
-c 1 \
-l INFO
/srv/pandora/bin/python \
/srv/pandora/pandora/manage.py \
celery worker \
-c 1 \
-Q encoding -n $name \
-l INFO
fi
if [ "$action" = "tasks" ]; then
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
/srv/pandora_base/docker/wait-for rabbitmq 5672
name=pandora-default-$(hostname)
cd /srv/pandora/pandora
exec /usr/bin/sudo -u $user -E -H \
/srv/pandora/bin/celery \
-A app worker \
-Q default,celery -n ${name} \
--pidfile /run/pandora/tasks.pid \
/srv/pandora/bin/python \
/srv/pandora/pandora/manage.py \
celery worker \
-Q default,celery -n $name \
--maxtasksperchild 1000 \
-l INFO
fi
if [ "$action" = "cron" ]; then
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
/srv/pandora_base/docker/wait-for rabbitmq 5672
cd /srv/pandora/pandora
exec /usr/bin/sudo -u $user -E -H \
/srv/pandora/bin/celery \
-A app beat \
-s /run/pandora/celerybeat-schedule \
/srv/pandora/bin/python \
/srv/pandora/pandora/manage.py \
celerybeat -s /run/pandora/celerybeat-schedule \
--pidfile /run/pandora/cron.pid \
-l INFO
fi
if [ "$action" = "websocketd" ]; then
/srv/pandora_base/docker/wait-for-file /srv/pandora/initialized
/srv/pandora_base/docker/wait-for rabbitmq 5672
cd /srv/pandora/pandora
exec /usr/bin/sudo -u $user -E -H \
/srv/pandora/bin/python \
/srv/pandora/pandora/manage.py websocketd
fi
# pan.do/ra management and update
if [ "$action" = "ctl" ]; then
if [ "$action" = "manage.py" ]; then
shift
exec /srv/pandora/ctl "$@"
exec /usr/bin/sudo -u $user -E -H \
/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
if [ "$action" = "bash" ]; then
shift

View file

@ -56,9 +56,13 @@ cp /srv/pandora/docker/entrypoint.sh /entrypoint.sh
mv /srv/pandora/ /srv/pandora_base/
mkdir /pandora
ln -s /pandora /srv/pandora
cat > /usr/local/bin/pandoractl << EOF
cat > /usr/local/bin/update.py << EOF
#!/bin/sh
exec /srv/pandora/ctl \$@
exec /srv/pandora/update.py \$@
EOF
chmod +x /usr/local/bin/pandoractl
cat > /usr/local/bin/manage.py << EOF
#!/bin/sh
exec /srv/pandora/pandora/manage.py \$@
EOF
chmod +x /usr/local/bin/manage.py /usr/local/bin/update.py

View file

@ -26,7 +26,7 @@ and to get started run this:
To update pan.do/ra run:
docker-compose run pandora ctl update
docker-compose run pandora update.py
EOF
touch __init__.py

View file

@ -1,5 +1,5 @@
#!/bin/sh
TIMEOUT=180
TIMEOUT=60
TARGET="$1"
for i in `seq $TIMEOUT` ; do

View file

@ -11,8 +11,6 @@ def run(cmd):
stdout, stderr = p.communicate()
if p.returncode != 0:
print('failed to run:', cmd)
print(stdout)
print(stderr)
sys.exit(1)

View file

@ -22,7 +22,7 @@ def get_location(ip):
else:
try:
location = g.city(ip)
except:
except GeoIP2Exception:
try:
location = g.country(s.ip)
except:

View file

@ -1,15 +1,14 @@
Django==3.0.10
simplejson
chardet
celery<5.0,>4.3
celery>4.3.0
django-celery-results
django-extensions==2.2.9
gunicorn==20.0.4
html5lib
requests<3.0.0,>=2.24.0
urllib3<2.0.0,>=1.25.2
requests==2.23.0
tornado<5
geoip2==4.1.0
geoip2==3.0.0
youtube-dl>=2020.5.8
python-memcached
elasticsearch