[enh] new app-list ciclic command

This commit is contained in:
Laurent Peuch 2019-01-20 07:12:55 +01:00
parent 05995b0f49
commit 29779f1a68
3 changed files with 26 additions and 1 deletions

View file

@ -160,6 +160,12 @@ Note that delete/restart will stop the job first to free the worker.
You will see a resulting log on the server for each action.
List apps:
```
$ ve3/bin/python ciclic app-list
```
# Deployment
You need to put this program behind a nginx mod proxy AND add the magical lines

13
ciclic
View file

@ -79,6 +79,17 @@ def list_(all=False, domain=DOMAIN):
print(f"{i['id']:4d} - {i['name']} [{i['state']}]")
def app_list(all=False, domain=DOMAIN):
response = request_api(
path="app",
verb="get",
domain=domain,
)
for i in response.json():
print(f"{i['name']} - {i['url']}")
def delete(job_id, domain=DOMAIN):
response = request_api(
path=f"job/{job_id}",
@ -126,4 +137,4 @@ def restart(job_id, domain=DOMAIN):
if __name__ == '__main__':
require_token()
argh.dispatch_commands([add, list_, delete, stop, restart])
argh.dispatch_commands([add, list_, delete, stop, restart, app_list])

8
run.py
View file

@ -617,6 +617,14 @@ async def api_list_job(request):
return response.json([model_to_dict(x) for x in query.order_by(-Job.id)])
@app.route("/api/app", methods=['GET'])
@require_token()
async def api_list_app(request):
query = Repo.select()
return response.json([model_to_dict(x) for x in query.order_by(-Repo.name)])
@app.route("/api/job/<job_id:int>", methods=['DELETE'])
@require_token()
async def api_delete_job(request, job_id):