File tree Expand file tree Collapse file tree 6 files changed +66
-3
lines changed Expand file tree Collapse file tree 6 files changed +66
-3
lines changed Original file line number Diff line number Diff line change 1+ *
2+ ! requirements.txt
3+ ! playbook.py
4+ ! server.py
5+ ! run.sh
6+ ! static
Original file line number Diff line number Diff line change 1+ FROM algo
2+ ARG BUILD_PACKAGES="gcc libffi-dev linux-headers make musl-dev openssl-dev"
3+ COPY requirements.txt /app/requirements.txt
4+ RUN apk --no-cache add ${BUILD_PACKAGES} && \
5+ source .env/bin/activate && \
6+ python3 -m pip --no-cache-dir install -r app/requirements.txt && \
7+ apk del ${BUILD_PACKAGES}
8+ COPY . app
9+ RUN chmod 0755 /algo/app/run.sh
10+ CMD [ "/algo/app/run.sh" ]
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -e
4+
5+ ALGO_DIR=" /algo"
6+ DATA_DIR=" /data"
7+
8+ if [ -z ${VIRTUAL_ENV+x} ]
9+ then
10+ ACTIVATE_SCRIPT=" /algo/.env/bin/activate"
11+ if [ -f " $ACTIVATE_SCRIPT " ]
12+ then
13+ # shellcheck source=/dev/null
14+ source " $ACTIVATE_SCRIPT "
15+ else
16+ echo " $ACTIVATE_SCRIPT not found. Did you follow documentation to install dependencies?"
17+ exit 1
18+ fi
19+ fi
20+
21+ tr -d ' \r' < " ${DATA_DIR} " /config.cfg > " ${ALGO_DIR} " /config.cfg
22+ test -d " ${DATA_DIR} " /configs && rsync -qLktr --delete " ${DATA_DIR} " /configs " ${ALGO_DIR} " /
23+ python app/server.py
24+ rsync -qLktr --delete " ${ALGO_DIR} " /configs " ${DATA_DIR} " /
25+ exit ${retcode}
Original file line number Diff line number Diff line change 33from os .path import join , dirname
44from aiohttp import web
55import concurrent .futures
6+ import sys
67from playbook import PlaybookCLI
78
89
@@ -85,6 +86,12 @@ async def post_config(request):
8586 f .write (config )
8687 return web .json_response ({'ok' : True })
8788
89+ @routes .post ('/exit' )
90+ async def post_exit (_ ):
91+ if task_future and task_future .done ():
92+ sys .exit (0 )
93+ else :
94+ sys .exit (1 )
8895
8996app = web .Application ()
9097app .router .add_routes (routes )
Original file line number Diff line number Diff line change @@ -61,7 +61,10 @@ <h1 class="mb-5 text-center" v-if="step === 'status-error'">
6161 😢 Set up failed
6262 </ h1 >
6363 < h1 class ="mb-5 text-center " v-if ="step === 'status-done' ">
64- 🥳 Congratulations! Your Algo server is running.
64+ 🥳 Congratulations, your Algo server is running!
65+ </ h1 >
66+ < h1 class ="mb-5 text-center " v-if ="step === 'status-exit' ">
67+ Config files are saved, bye!
6568 </ h1 >
6669 </ h1 >
6770 < transition name ="fade ">
@@ -99,7 +102,8 @@ <h1 class="mb-5 text-center" v-if="step === 'status-done'">
99102 </ section >
100103 </ transition >
101104 < transition name ="fade ">
102- < status-done v-if ="step == 'status-done' ">
105+ < status-done v-if ="step == 'status-done' "
106+ v-on:submit ="exit(); step = 'status-exit' " >
103107 </ status-done >
104108 </ transition >
105109 </ div >
@@ -126,7 +130,7 @@ <h1 class="mb-5 text-center" v-if="step === 'status-done'">
126130 'provider-setup' : window . httpVueLoader ( '/static/provider-setup.vue' ) ,
127131 'command-preview' : window . httpVueLoader ( '/static/command-preview.vue' ) ,
128132 'status-running' : window . httpVueLoader ( '/static/status-running.vue' ) ,
129- 'status-done' : window . httpVueLoader ( '/static/status-done.vue' ) ,
133+ 'status-done' : window . httpVueLoader ( '/static/status-done.vue' )
130134 } ,
131135 created ( ) {
132136 fetch ( "/playbook" )
@@ -154,6 +158,11 @@ <h1 class="mb-5 text-center" v-if="step === 'status-done'">
154158 fetch ( "/playbook" , {
155159 method : "DELETE"
156160 } ) ;
161+ } ,
162+ exit ( ) {
163+ fetch ( "/exit" , {
164+ method : "POST"
165+ } ) ;
157166 }
158167 }
159168 } )
Original file line number Diff line number Diff line change 3636 </div >
3737 </div >
3838 </section >
39+ <section >
40+ <h2 class =" text-center" >Finish setup and save configs</h2 >
41+ <p class =" text-center" >
42+ <button v-on:click =" $emit('submit')" class =" btn btn-primary btn-lg" type =" button" >Save & ; Exit</button >
43+ </p >
44+ </section >
3945 </div >
4046</template >
4147
You can’t perform that action at this time.
0 commit comments