2020-03-18 12:32:40 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
if [ -v $OSHIPKA_PATH ]; then
|
|
|
|
echo "You need to specify OSHIPKA_PATH env variable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "oshipka is at: $OSHIPKA_PATH"
|
|
|
|
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
HELP="
|
2020-03-19 14:13:58 +01:00
|
|
|
Usage $0 [ bootstrap | worker | web ]
|
2020-03-18 12:32:40 +01:00
|
|
|
|
|
|
|
bootstrap [PROJECT_PATH] Create a new project in PROJECT_PATH
|
2020-03-19 14:13:58 +01:00
|
|
|
worker Start worker
|
|
|
|
web Start webapp
|
2020-03-18 12:32:40 +01:00
|
|
|
"
|
|
|
|
|
2020-03-19 14:13:58 +01:00
|
|
|
worker () {
|
|
|
|
celery worker --app=tasks.worker.worker_app --concurrency=1 --loglevel=INFO
|
|
|
|
}
|
|
|
|
|
|
|
|
web () {
|
|
|
|
python run.py
|
|
|
|
}
|
|
|
|
|
2020-03-18 12:32:40 +01:00
|
|
|
bootstrap() {
|
|
|
|
shift
|
|
|
|
PROJECT_PATH=$1
|
|
|
|
if [[ -z "$PROJECT_PATH" ]]; then
|
|
|
|
read -p "Enter project path: " PROJECT_PATH
|
|
|
|
fi
|
|
|
|
if [[ -z "$PROJECT_PATH" ]]; then
|
|
|
|
echo "ERROR: Specify project path"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "INFO: Project path: $PROJECT_PATH"
|
|
|
|
PROJECT_PATH=`realpath $PROJECT_PATH`
|
|
|
|
echo "INFO: Absolute project path: $PROJECT_PATH"
|
|
|
|
if [[ "$PROJECT_PATH" == $OSHIPKA_PATH* ]]; then
|
|
|
|
echo "ERROR: Project path can't be inside this directory. Exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -d $PROJECT_PATH ]; then
|
|
|
|
echo "ERROR: Project path exists. Please remove or specify another. Exiting..."
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "INFO: Project path doesn't exist, creating..."
|
|
|
|
mkdir -p $PROJECT_PATH
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
PROJECT_NAME=$(basename $PROJECT_PATH)
|
|
|
|
echo "INFO: Bootstrapping project $PROJECT_NAME..."
|
|
|
|
mkdir -p ${PROJECT_PATH}
|
|
|
|
cp -r ${OSHIPKA_PATH}/bootstrap/* ${PROJECT_PATH}/
|
|
|
|
}
|
|
|
|
|
|
|
|
command_main() {
|
|
|
|
INITIAL_COMMAND=$1
|
|
|
|
case "$INITIAL_COMMAND" in
|
|
|
|
bootstrap) bootstrap "$@"
|
2020-03-19 14:13:58 +01:00
|
|
|
;;
|
|
|
|
worker) worker "$@"
|
|
|
|
;;
|
|
|
|
web) web "$@"
|
2020-03-18 12:32:40 +01:00
|
|
|
;;
|
|
|
|
*) >&2 echo -e "${HELP}"
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
command_main "$@"
|