Add teardown script
This commit is contained in:
parent
4e5bf34ece
commit
52efcc9e0f
5 changed files with 22 additions and 8 deletions
|
@ -7,10 +7,5 @@
|
|||
- import_tasks: ./tasks/common/zsh.yml
|
||||
- import_tasks: ./tasks/common/docker.yml
|
||||
- import_tasks: ./tasks/network/avahi.yml
|
||||
# - import_tasks: tasks/zsh.yml
|
||||
# - import_tasks: tasks/nginx.yml
|
||||
# - import_tasks: tasks/pi-hole.yml
|
||||
# - import_tasks: tasks/pi-vpn.yml
|
||||
# - import_tasks: tasks/nextcloud.yml
|
||||
# - name: Reboot machine
|
||||
# reboot:
|
||||
|
|
6
ansible/stop.yml
Normal file
6
ansible/stop.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- hosts: tipi
|
||||
become: yes
|
||||
|
||||
tasks:
|
||||
- import_tasks: ./tasks/common/teardown.yml
|
9
ansible/tasks/common/teardown.yml
Normal file
9
ansible/tasks/common/teardown.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
- name: Check if app is already running
|
||||
become_user: "{{ username }}"
|
||||
shell: pm2 list
|
||||
register: pm2_result
|
||||
|
||||
- name: Stop app
|
||||
become_user: "{{ username }}"
|
||||
shell: pm2 stop "system-api"
|
||||
when: pm2_result.stdout.find("system-api") != -1
|
|
@ -21,6 +21,8 @@ STATE_FOLDER="${ROOT_FOLDER}/state"
|
|||
|
||||
cd "$ROOT_FOLDER"
|
||||
|
||||
ansible-playbook ansible/stop.yml -i ansible/hosts
|
||||
|
||||
export DOCKER_CLIENT_TIMEOUT=240
|
||||
export COMPOSE_HTTP_TIMEOUT=240
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import { Request, Response } from 'express';
|
||||
import process from 'child_process';
|
||||
import config from '../../config';
|
||||
import { AppConfig } from '../../config/types';
|
||||
import { createFolder, fileExists, readJsonFile, writeFile, copyFile, runScript, deleteFolder } from '../fs/fs.helpers';
|
||||
|
||||
|
@ -153,7 +151,11 @@ const installedApps = (req: Request, res: Response) => {
|
|||
const apps = readJsonFile('/state/apps.json');
|
||||
const appNames = apps.installed.split(' ');
|
||||
|
||||
res.status(200).json(appNames);
|
||||
if (appNames.length === 0) {
|
||||
res.status(204).json([]);
|
||||
} else {
|
||||
res.status(200).json(appNames);
|
||||
}
|
||||
} catch (e) {
|
||||
res.status(500).end(e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue