Skip to content

Commit

Permalink
README and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Jan 11, 2025
1 parent 5a677b2 commit 2a84bbe
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 7 deletions.
69 changes: 62 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<h1><a href="https://github.com/aceberg/AnyAppStart">
<img src="https://raw.githubusercontent.com/aceberg/AnyAppStart/main/assets/logo.png" width="20" />
</a>AnyAppStart</h1>
<br/>

Universal app to `Start`/`Stop`/`Restart`/`View Logs` for any Type of service (Docker, Systemd, VMs, remote, user scripts)
[![Main-Docker](https://github.com/aceberg/AnyAppStart/actions/workflows/main-docker.yml/badge.svg)](https://github.com/aceberg/AnyAppStart/actions/workflows/main-docker.yml)
![GitHub License](https://img.shields.io/github/license/aceberg/AnyAppStart)

Universal app to `Start`/`Stop`/`Restart`/`View Logs` for any Type of service (Docker, Systemd, VMs, LXC, remote, user scripts)

- Backend: `Go`, Frontend: `React`, `TypeScript`, `MobX`
- Small lightweight app, easy to set up and configure
Expand All @@ -21,13 +23,13 @@ Universal app to `Start`/`Stop`/`Restart`/`View Logs` for any Type of service (D

</details>

## Install
## Installation
<details>
<summary>Expand</summary>

> :warning: **Warning**
> 1. There is Docker image available, but inside the container only Docker Type will work, which kinda defeats the purpose of this app. So installing binary is recommended.
> 2. There is no built-in auth in this app, so make sure to restrict access to it with firewall and/or SSO (Authelia) or simple [ForAuth](https://github.com/aceberg/ForAuth)
> 2. There is no built-in auth in this app, so make sure to restrict access to it with firewall and/or SSO (like Authelia) or simple [ForAuth](https://github.com/aceberg/ForAuth)
### Binary
All binary packages can be found in [latest](https://github.com/aceberg/AnyAppStart/releases/latest) release. There are `.deb`, `.rpm`, `.apk` (Alpine Linux) and `.tar.gz` files.
Expand All @@ -37,18 +39,62 @@ Supported architectures: `amd64`, `i386`, `arm_v5`, `arm_v6`, `arm_v7`, `arm64`.
For `amd64` there is a `deb` repo [available](https://github.com/aceberg/ppa)

### Docker
For demo purpose, mostly.
For demo purposes, mostly.
```sh
docker run --name AnyAppStart \
-e "TZ=$YOURTIMEZONE" \
-v ~/.dockerdata/AnyAppStart:/data/AnyAppStart \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ~/.dockerdata/AnyAppStart:/data/AnyAppStart \ # yaml files here
-v /var/run/docker.sock:/var/run/docker.sock \ # mount docker
-p 8855:8855 \
aceberg/anyappstart
```

</details>

## Usage
<details>
<summary>Expand</summary>

To run AnyAppStart as user, enable and start it:
```sh
sudo systemctl enable --now AnyAppStart@$USER.service
```
After, you need to fill `types.yaml` file, either manually by clicking `Add Type` in GUI Types menu, or by copying this [types.yaml](https://github.com/aceberg/AnyAppStart/blob/main/example/types.yaml) example to `~/.config/AnyAppStart/` (or `/etc/AnyAppStart/` for root)
```yaml
Docker:
Logs: docker logs $ITEMNAME
Restart: docker restart $ITEMNAME
Start: docker start $ITEMNAME
State: docker ps --filter status=running | grep $ITEMNAME
Stop: docker stop $ITEMNAME
Systemd:
Logs: sudo systemctl status $ITEMNAME
Restart: sudo systemctl restart $ITEMNAME
Start: sudo systemctl start $ITEMNAME
State: sudo systemctl | grep running | grep $ITEMNAME
Stop: sudo systemctl stop $ITEMNAME
VM:
Logs: sudo journalctl -u libvirtd.service
Restart: sudo virsh rebool $ITEMNAME
Start: sudo virsh start $ITEMNAME
State: sudo virsh list --state-running | grep $ITEMNAME
Stop: sudo virsh shutdown $ITEMNAME
ssh-Docker:
Logs: ssh remote-host-ip -f docker logs $ITEMNAME
Restart: ssh remote-host-ip -f docker restart $ITEMNAME
Start: ssh remote-host-ip -f docker start $ITEMNAME
State: ssh remote-host-ip -f docker ps --filter status=running | grep $ITEMNAME
Stop: ssh remote-host-ip -f docker stop $ITEMNAME
ssh-Systemd:
Logs: ssh remote-host-ip -f sudo systemctl status $ITEMNAME
Restart: ssh remote-host-ip -f sudo systemctl restart $ITEMNAME
Start: ssh remote-host-ip -f sudo systemctl start $ITEMNAME
State: ssh remote-host-ip -f sudo systemctl | grep running | grep $ITEMNAME
Stop: ssh remote-host-ip -f systemctl stop $ITEMNAME
```
</details>
## Config
<details>
<summary>Expand</summary>
Expand All @@ -74,6 +120,15 @@ aceberg/anyappstart
</details>
## Build (for devs) and API
<details>
<summary>Expand</summary>
- API: [docs/API.md](docs/API.md)
- Build: [docs/BUILD.md](docs/BUILD.md)
</details>
## Thanks
<details>
<summary>Expand</summary>
Expand Down
61 changes: 61 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## API
```http
GET /api/conf
```
Get app config


```http
GET /api/exec?name=NAME&type=TYPE&exec=EXEC
```
Execute a command, where
- `NAME` - Item name
- `TYPE` - Item Type
- `EXEC` - one of the commands: Start, Stop, Restart, Logs, State

Returns:
- `Ok` - `true` or, if error occurred `false`
- `Out` - command output

<details>
<summary>Example</summary>

```sh
curl "http://0.0.0.0:8855/api/exec?name=wyl&type=Docker&exec=Start"
```
```json
{
"Ok": true,
"Out": "wyl\n"
}
```

</details>
<br>

```http
GET /api/items
```
Get all Items with their current states

```http
GET /api/types
```
Get all Types

```http
POST /api/conf
```
Save config variable `conf`. Example: `data.set('conf', JSON.stringify(conf))`
```http
POST /api/item
```
Edit Item. Variables:
- `old` - old Item
- `new` - new Item (empty Name to delete Item)
```http
POST /api/type
```
Edit Type. Variables:
- `old` - old Type
- `new` - new Type (empty Name to delete Type)
40 changes: 40 additions & 0 deletions docs/BUILD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# For developers

This app has separate frontend (`React`) and backend (`Go`). You need to run both of them to see modifications while editing the code.

## Dev

1. Backend
```sh
cd backend/ #
make check # check golang code
make run # run backend
```
The backend needs to be restarted to apply any modifications to it!

2. Frontend
```sh
cd frontend/
npm i # install node modules
npm run dev # run frontend
```
Make sure the `api` port in `frontend/src/functions/api.tsx` is the same the backend uses.

## Build
To build the app in a single file, there is a `frontend/Makefile`:
```sh
cd frontend/
make all
```
Edit the `api` port in the Makefile if needed.

Then I just push the code to Github and let Actions build Docker and Binary files for me=)

### Build locally
To build binary locally, after the steps above, run:

```sh
cd backend/
make go-build
```
Binary file will be in `backend/tmp/AnyAppStart`

0 comments on commit 2a84bbe

Please sign in to comment.