Scripts

Version 10 (Paul Carensac, 08/11/2016 04:46 pm)

1 1 Paul Carensac
h1. Scripts
2 1 Paul Carensac
3 5 Paul Carensac
Explanations about the scripts. 
4 1 Paul Carensac
5 3 Paul Carensac
{{>toc}}
6 3 Paul Carensac
7 1 Paul Carensac
---
8 1 Paul Carensac
9 6 Paul Carensac
Most of them are located in src/scripts/ folder :
10 1 Paul Carensac
11 5 Paul Carensac
h3. celery_test.sh / .bat
12 5 Paul Carensac
13 1 Paul Carensac
 * *Goal*
14 1 Paul Carensac
    Run tests using the production database in order to see the celery results (celery is always running on production database).
15 1 Paul Carensac
16 4 Paul Carensac
 * *Argument(s)*
17 2 Paul Carensac
    You need to give the app / TestClass / test_name to run it (prevents a fail test launching, polluting the production DB)
18 2 Paul Carensac
19 1 Paul Carensac
 * *How it works ?*
20 1 Paul Carensac
21 1 Paul Carensac
  * Uses sed command to set CELERY_TEST variable to 'True' in settings.py (The consequence is that the production DB will be chosen for tests in settings.py)
22 6 Paul Carensac
  * Creates a fresh test sqlite database, and populate it with misc/fixtures/initial_fixtures.json
23 6 Paul Carensac
  * Starts the simulators, then celery
24 6 Paul Carensac
  * Runs the test(s) you gave with --keepdb and --nomigrations
25 6 Paul Carensac
  * Stops the simulators and celery workers
26 2 Paul Carensac
27 2 Paul Carensac
h3. delete_all_request.sh
28 2 Paul Carensac
29 2 Paul Carensac
 * *Goal*
30 2 Paul Carensac
    Deletes all the Alerts, Requests, Sequences, Albums and Plan from the current DB (the one chosen in settings.py)
31 2 Paul Carensac
    The goal is to easily clean the DB
32 2 Paul Carensac
33 2 Paul Carensac
 * *How it works ?*
34 2 Paul Carensac
35 2 Paul Carensac
  * Moves to src/ folder
36 2 Paul Carensac
  * Checks in settings.py whether MySQL or SQLite is used
37 2 Paul Carensac
  * Uses SQL inline command to delete the fields in the current DB
38 2 Paul Carensac
39 2 Paul Carensac
40 5 Paul Carensac
h3. kill_celery_workers.sh / .bat
41 2 Paul Carensac
42 2 Paul Carensac
 * *Goal*
43 2 Paul Carensac
    Deletes all the celery workers running (in background, or not)
44 2 Paul Carensac
45 2 Paul Carensac
 * *How it works ?*
46 2 Paul Carensac
47 1 Paul Carensac
  * Lists all the process running on the computer
48 2 Paul Carensac
  * Looks for "celery worker" matching one
49 2 Paul Carensac
  * Gets their PIDs
50 2 Paul Carensac
  * Send them a kill -9 message
51 2 Paul Carensac
52 2 Paul Carensac
53 5 Paul Carensac
h3. start_celery_worker.sh / .bat
54 2 Paul Carensac
55 2 Paul Carensac
 * *Goal*
56 1 Paul Carensac
    Starts the celery workers, giving them a queue and a name
57 1 Paul Carensac
58 1 Paul Carensac
 * *How it works ?*
59 1 Paul Carensac
60 1 Paul Carensac
  * Moves to src/ folder
61 1 Paul Carensac
  * Kills the workers still running
62 1 Paul Carensac
  * Starts every worker one by one (in background using '&'), giving them a queue, a name, and purging the associated queue if needed
63 5 Paul Carensac
64 5 Paul Carensac
65 5 Paul Carensac
h3. test_all_usual.sh / .bat
66 5 Paul Carensac
67 5 Paul Carensac
 * *Goal*
68 5 Paul Carensac
    Run all the tests that don't need celery
69 5 Paul Carensac
70 5 Paul Carensac
 * *How it works ?*
71 5 Paul Carensac
72 5 Paul Carensac
  * Just use python manage.py test command with all the wanted tests
73 5 Paul Carensac
74 5 Paul Carensac
75 5 Paul Carensac
---
76 5 Paul Carensac
77 5 Paul Carensac
They are also two scripts in the simulators/ folder : 
78 5 Paul Carensac
79 5 Paul Carensac
80 5 Paul Carensac
h3. run_all.sh
81 5 Paul Carensac
82 5 Paul Carensac
 * *Goal*
83 5 Paul Carensac
    Run all the simulators in background
84 5 Paul Carensac
85 5 Paul Carensac
 * *How it works ?*
86 5 Paul Carensac
87 5 Paul Carensac
  * Launches each simulator in background with python
88 5 Paul Carensac
89 5 Paul Carensac
h3. kill_all.sh
90 5 Paul Carensac
91 5 Paul Carensac
 * *Goal*
92 5 Paul Carensac
    Kill all simulators process in background
93 5 Paul Carensac
94 5 Paul Carensac
 * *How it works ?*
95 5 Paul Carensac
96 5 Paul Carensac
  * Finds the process IDs corresponding to the simulators and kills them
97 5 Paul Carensac
98 5 Paul Carensac
---
99 5 Paul Carensac
100 5 Paul Carensac
The script that should be used by users to run the project's functionalities is in the PYROS/ root folder :
101 5 Paul Carensac
102 5 Paul Carensac
h3. pyrosrun.sh / .bat
103 5 Paul Carensac
104 5 Paul Carensac
 * *Goal*
105 5 Paul Carensac
    Allow to run every feature of the project from its root (runserver, tests, celery, ...)
106 5 Paul Carensac
107 5 Paul Carensac
 * *How it works ?*
108 5 Paul Carensac
109 1 Paul Carensac
  * It calls the manage.py commands and the other scripts, according to the given parameters (see the usage message) <== This script should be improved before the 12/08/2016
110 7 Paul Carensac
111 7 Paul Carensac
 * *Possible commands :*
112 7 Paul Carensac
113 7 Paul Carensac
  * 'server' : Runs the web server
114 1 Paul Carensac
  * 'updatedb' : Update the database
115 10 Paul Carensac
  * 'unittest' : Runs the tests that don't need celery
116 7 Paul Carensac
  * 'test_all' : Run all the existing tests (this command needs to be updated when tests are added in the project)
117 7 Paul Carensac
  * 'celery_on' : Starts the celery workers
118 7 Paul Carensac
  * 'celery_off' : Stops the celery workers
119 7 Paul Carensac
  * 'simul_on' : Starts the simulators
120 7 Paul Carensac
  * 'simul_off' : Stops the simulators
121 9 Paul Carensac
  * 'start' : Starts the simulators then the celery workers, then the web server
122 8 Paul Carensac
  * 'stop' : Stops the celery workers then the simulators