Skip to content

Commit 3333e8b

Browse files
authored
Merge pull request #42 from mekanix/feature/init
Setup a project
2 parents 970d08c + 8842700 commit 3333e8b

File tree

20 files changed

+98
-58
lines changed

20 files changed

+98
-58
lines changed

bin/freenit.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,27 @@ fi
1111
PROJECT_ROOT=`python${PY_VERSION} -c 'import os; import freenit; print(os.path.dirname(os.path.abspath(freenit.__file__)))'`
1212

1313

14-
mkdir ${NAME}
15-
touch ${NAME}/__init__.py
1614
echo 'freenit' >requirements.txt
1715
cp -r ${PROJECT_ROOT}/project/* .
18-
mv api ${NAME}
19-
mv models ${NAME}
20-
mv schemas ${NAME}
16+
mv project ${NAME}
2117
echo "app_name=\"${NAME}\" # noqa: E225" >name.py
2218
echo "ipdb" >requirements_dev.txt
19+
echo "DEVEL_MODE = YES" >vars.mk
20+
cat > Makefile << EOF
21+
.include <name.py>
22+
23+
SERVICE != echo \${app_name}back
24+
REGGAE_PATH := /usr/local/share/reggae
25+
SYSPKG := YES
26+
27+
shell: up
28+
@sudo cbsd jexec user=devel jname=\${SERVICE} /usr/src/bin/shell.sh
29+
30+
init: up
31+
@sudo cbsd jexec jname=\${SERVICE} env OFFLINE=\${offline} SYSPKG=\${SYSPKG} /usr/src/bin/init.sh
32+
33+
do_devel:
34+
@sudo cbsd jexec jname=\${SERVICE} env OFFLINE=\${offline} SYSPKG=\${SYSPKG} /usr/src/bin/devel.sh
35+
36+
.include <\${REGGAE_PATH}/mk/service.mk>
37+
EOF

freenit/project/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.provisioned
2+
ansible/group_vars/all
3+
ansible/inventory/inventory
4+
ansible/roles/*
5+
ansible/site.yml
6+
!ansible/roles/.keep
7+
build/
8+
cbsd.conf
9+
site.retry
10+
project.mk
11+
vars.mk

freenit/project/bin/build.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,3 @@ BIN_DIR=`dirname $0`
66
setup
77

88
flask collect --verbose
9-
rm -rf pyser/static

freenit/project/bin/common.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
#!/bin/sh
22

3-
3+
export LC_ALL=C.UTF-8
4+
export LANG=C.UTF-8
45
export BIN_DIR=`dirname $0`
56
export PROJECT_ROOT="${BIN_DIR}/.."
67
. "${PROJECT_ROOT}/name.py"
78
export VIRTUALENV=${VIRTUALENV:="${app_name}back"}
89
export FLASK_ENV=${FLASK_ENV:="production"}
910
export PY_VERSION=${PY_VERSION:="3.7"}
11+
export SYSPKG=${SYSPKG:="no"}
1012

1113

1214
setup() {
13-
update=${1}
14-
if [ ! -d ${HOME}/.virtualenvs/${VIRTUALENV} ]; then
15-
python${PY_VERSION} -m venv "${HOME}/.virtualenvs/${VIRTUALENV}"
16-
fi
17-
. ${HOME}/.virtualenvs/${VIRTUALENV}/bin/activate
15+
cd "${PROJECT_ROOT}"
16+
if [ "${SYSPKG}" = "no" ]; then
17+
update=${1}
18+
if [ ! -d ${HOME}/.virtualenvs/${VIRTUALENV} ]; then
19+
python${PY_VERSION} -m venv "${HOME}/.virtualenvs/${VIRTUALENV}"
20+
fi
21+
. ${HOME}/.virtualenvs/${VIRTUALENV}/bin/activate
1822

19-
cd ${PROJECT_ROOT}
20-
if [ "${update}" != "no" ]; then
21-
pip install -U pip
22-
pip install -U wheel
23-
pip install -U -r requirements.txt
24-
fi
25-
if [ -e "${BIN_DIR}/../migrations/main/001_initial.py" ]; then
26-
flask migration run
23+
cd ${PROJECT_ROOT}
24+
if [ "${update}" != "no" ]; then
25+
pip install -U pip
26+
pip install -U wheel
27+
pip install -U -r requirements.txt
28+
fi
2729
fi
2830
}

freenit/project/bin/devel.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,23 @@
22

33

44
BIN_DIR=`dirname $0`
5+
PROJECT_ROOT="${BIN_DIR}/.."
56
export FLASK_PORT=${FLASK_PORT:=5000}
67
export FLASK_ENV="development"
8+
API_ROOT="http://`hostname`:${FLASK_PORT}/doc/swaggerui"
79
export OFFLINE=${OFFLINE:=no}
10+
export SYSPKG=${SYSPKG:="no"}
811

912

1013
. ${BIN_DIR}/common.sh
1114
setup no
1215

1316

14-
if [ "${OFFLINE}" != "yes" ]; then
15-
pip install -U -r requirements_dev.txt
17+
cd "${PROJECT_ROOT}"
18+
if [ "${SYSPKG}" = "no" ]; then
19+
if [ "${OFFLINE}" != "yes" ]; then
20+
pip install -U -r requirements_dev.txt
21+
fi
1622
fi
1723

1824

freenit/project/bin/gunicorn.sh

Lines changed: 0 additions & 22 deletions
This file was deleted.

freenit/project/bin/init.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ if [ "${OFFLINE}" = "yes" ]; then
1010
else
1111
setup
1212
fi
13-
14-
15-
if [ ! -e "${BIN_DIR}/../migrations/main/001_initial.py" ]; then
16-
flask migration create initial
17-
flask migration run
18-
fi
13+
flask migration run
1914
flask admin create
15+
flask gallery create

freenit/project/bin/uwsgi.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
4+
BIN_DIR=`dirname $0`
5+
PROJECT_ROOT="${BIN_DIR}/.."
6+
PROCESSES=4
7+
WSGI_MODULE=wsgi
8+
PORT=${PORT:=9000}
9+
export FLASK_ENV="production"
10+
11+
. ${BIN_DIR}/common.sh
12+
setup
13+
pip install -U uwsgi
14+
15+
16+
cd ${PROJECT_ROOT}
17+
exec uwsgi \
18+
--wsgi-file ${WSGI_MODULE}.py \
19+
--master \
20+
--processes ${PROCESSES} \
21+
--uwsgi-socket :${PORT} \
22+
--vacuum

freenit/project/devel.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
from importlib import import_module
1+
from freenit import create_app
22

33
from config import configs
4-
from name import app_name
54

6-
application = import_module(f'{app_name}')
75
config = configs['development']
8-
app = application.create_app(config)
6+
app = create_app(config)
File renamed without changes.

0 commit comments

Comments
 (0)