Blame view

pyrosrun.sh 2.33 KB
42983157   haribo   #3443 pyrosrun sc...
1
2
#!/bin/bash

0f60ca69   haribo   pyrosrun script u...
3
4
5
6
7
8
9
10
11
12
COMMANDS="\n
\t'server' : Runs the web server\n
\t'updatedb' : Update the database\n
\t'unittest' : Runs the tests that don't need celery\n
\t'test_all' : Run all the existing tests (this command needs to be updated when tests are added in the project)\n
\t'celery_on' : Starts the celery workers\n
\t'celery_off' : Stops the celery workers\n
\t'simul_on' : Starts the simulators\n
\t'simul_off' : Stops the simulators\n
\t'start' : Starts the simulators then the celery workers, then the web server\n
d91a4c2b   Jeremy   Inserted logger
13
\t'stop' : Stops the celery workers then the simulators\n
2d95ba4e   Jeremy   simulator module ...
14
\t'clean_logs' : Clear all pyros .log files from /logs\n
d5611ba1   Jeremy   Routine simulator...
15
16
17
\t'simulator' : Launch routine simulator\n
\t'kill_simulation : Kill web server and celery tasks (only use during simulation)'\n
\t'sim : start only simulation task'"
2d95ba4e   Jeremy   simulator module ...
18
#\t'test_runserver' : Launch web server on test database
0f60ca69   haribo   pyrosrun script u...
19

00bc9770   Etienne Pallier   fix pyrosrun
20
21
NEEDED_COMMAND="One command is needed. Possible commands : $COMMANDS"
INVALID_COMMAND="Invalid command. Possible commands : $COMMANDS"
0f60ca69   haribo   pyrosrun script u...
22
23
24
25
26

SCRIPT_PATH=$0
SCRIPT_PATH=${SCRIPT_PATH%/*}

cd $SCRIPT_PATH
42983157   haribo   #3443 pyrosrun sc...
27

419720e2   carens_p   pyrosrun.sh
28
source private/venv_py3_pyros/bin/activate
42983157   haribo   #3443 pyrosrun sc...
29
30

if [ $# -ne 1 ]; then
0f60ca69   haribo   pyrosrun script u...
31
   echo -e $NEEDED_COMMAND
42983157   haribo   #3443 pyrosrun sc...
32
33
34
35
36
37
38
39
40
   exit
fi

cd src/

case "$1" in
     "server")
	python manage.py runserver
	;;
0f60ca69   haribo   pyrosrun script u...
41
     "updatedb")
984e74ea   haribo   Moving non-app di...
42
43
44
	python manage.py makemigrations
	python manage.py migrate
	;;
0f60ca69   haribo   pyrosrun script u...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
     "unittest")
	scripts/test_all_usual.sh
	;;
     "test_all")
	scripts/test_all_usual.sh
	scripts/celery_test.sh alert_manager.tests.AlertListenerTestsCelery
	# ADD HERE ALL THE CELERY TESTS
	;;
     "celery_on")
     scripts/start_celery_workers.sh
	;;
     "celery_off")
     scripts/kill_celery_workers.sh
	;;
     "simul_on")
     cd ../simulators
     ./run_all.sh
     cd -
	;;
     "simul_off")
     cd ../simulators
     ./kill_all.sh
     cd -
	;;
     "start")
     cd ../simulators
     ./run_all.sh
     cd -
     scripts/start_celery_workers.sh
     python manage.py runserver
	;;
     "stop")
     scripts/kill_celery_workers.sh
     cd ../simulators
     ./kill_all.sh
     cd -
	;;
b5e9fde1   Jeremy   Update django ver...
82
     "clean_logs")
d91a4c2b   Jeremy   Inserted logger
83
84
85
86
     cd ../logs
     rm -f *.log
     cd -
	;;
2d95ba4e   Jeremy   simulator module ...
87
88
89
90
91
92
93
     "simulator")
     scripts/simulator_launch.sh
#     python manage.py test --pattern="testRoutine*.py" --keepdb
	;;
     "kill_simulation")
     scripts/kill_simulation.sh
	;;
d5611ba1   Jeremy   Routine simulator...
94
95
96
     "sim")
     celery worker -A pyros -Q simulator_q -n pyros@simulator -c 1 &
	;;
42983157   haribo   #3443 pyrosrun sc...
97
     *)
0f60ca69   haribo   pyrosrun script u...
98
	echo -e $INVALID_COMMAND
42983157   haribo   #3443 pyrosrun sc...
99
100
	;;
esac