added quick setup & start for linux

This commit is contained in:
tcsenpai 2024-11-17 20:00:48 +01:00
parent 36af2346c8
commit c34b6da14d
5 changed files with 177 additions and 0 deletions

55
environment.yml Normal file
View File

@ -0,0 +1,55 @@
name: memos
channels:
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- bzip2=1.0.8=h5eee18b_6
- ca-certificates=2024.9.24=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- libuuid=1.41.5=h5eee18b_0
- ncurses=6.4=h6a678d5_0
- openssl=3.0.15=h5eee18b_0
- pip=24.2=py310h06a4308_0
- python=3.10.15=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.1.0=py310h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2024b=h04d1e81_0
- wheel=0.44.0=py310h06a4308_0
- xz=5.4.6=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- certifi==2024.8.30
- colorama==0.4.6
- coloredlogs==15.0.1
- dbus-python==1.3.2
- einops==0.8.0
- fastapi==0.115.5
- humanfriendly==10.0
- imagehash==4.3.1
- magika==0.5.1
- memos==0.18.7
- modelscope==1.20.1
- mss==10.0.0
- onnxruntime==1.20.0
- piexif==1.1.3
- psutil==6.1.0
- py-cpuinfo==9.0.0
- pydantic-settings==2.6.1
- python-xlib==0.33
- pywavelets==1.7.0
- rapidocr-onnxruntime==1.3.25
- shellingham==1.5.4
- six==1.16.0
- sqlite-vec==0.1.5
- starlette==0.41.2
- termcolor==2.5.0
- timm==1.0.11
- typer==0.13.0
- uvicorn==0.32.0

0
linuxdeps.sh Normal file → Executable file
View File

24
local_setup.sh Executable file
View File

@ -0,0 +1,24 @@
#! /bin/bash
# Build web app
cd web
yarn || exit 1
yarn build || exit 1
cd ..
# Install linux dependencies
./linuxdeps.sh || exit 1
# Install python dependencies in conda environment
conda env create -f environment.yml || exit 1
# Activate conda environment
conda activate memos || exit 1
# Initialize database
python memos_app.py init || exit 1
# Deactivate and exit
conda deactivate
echo "Setup complete. Please run 'conda activate memos' to use the environment and then 'python start.py' to start the full app."
echo "You can also run 'source start.sh' to start the full app in one go."

94
start.py Normal file
View File

@ -0,0 +1,94 @@
import subprocess
import threading
import sys
import signal
from colorama import init, Fore
import time
# Initialize colorama for Windows compatibility
init()
# Define colors for each process
COLORS = [Fore.GREEN, Fore.BLUE, Fore.YELLOW]
def run_process(command, color):
"""Run a single process with colored output."""
try:
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
bufsize=1,
universal_newlines=True,
)
while True:
line = process.stdout.readline()
if not line and process.poll() is not None:
break
if line:
print(f"{color}{command[0]}: {line.rstrip()}{Fore.RESET}")
return process.poll()
except Exception as e:
print(f"{Fore.RED}Error in {command[0]}: {str(e)}{Fore.RESET}")
return 1
def main():
# Define your three commands here
commands = [
["python", "memos_app.py", "record"],
["python", "memos_app.py", "serve"],
["python", "memos_app.py", "watch"],
]
# Create threads for each process
threads = []
processes = []
def signal_handler(signum, frame):
print(f"\n{Fore.RED}Interrupting all processes...{Fore.RESET}")
for process in processes:
process.terminate()
sys.exit(0)
# Set up signal handlers
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
# Run processes in separate threads
for i, command in enumerate(commands):
time.sleep(3)
color = COLORS[i % len(COLORS)]
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
text=True,
bufsize=1,
universal_newlines=True,
)
processes.append(process)
thread = threading.Thread(target=run_process, args=(command, color))
thread.start()
threads.append(thread)
print(f"Started {command[0]} with PID {process.pid}")
# Wait for all threads to complete
for thread in threads:
thread.join()
# Check for any failed processes
failed_processes = [process for process in processes if process != 0]
if failed_processes:
print(f"\n{Fore.RED}Some processes failed: {failed_processes}{Fore.RESET}")
else:
print(f"\n{Fore.GREEN}All processes completed successfully!{Fore.RESET}")
if __name__ == "__main__":
main()

4
start.sh Executable file
View File

@ -0,0 +1,4 @@
#! /usr/bin/env bash
conda activate memos || exit 1
python start.py