diff --git a/README.md b/README.md index 977af52..3d83daa 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Fluxer Reaper is a simple tool to help you move an entire Discord server over to ## Notes: - The Discord bot has read-only access to the source server. Hence no changes will be made to the source server. -- Currently Fluxer is unstable probably due to high traffic, migrating servers now will only add to that problem. Only use this for testing purposes for now. [Check status here](https://uptime.reallyaweso.me/status/fluxer) +- Currently Fluxer is unstable probably due to high traffic, migrating servers now will only add to that problem. Only use this for testing purposes for now. [Check status here](https://fluxerstatus.com) # Bot Setup diff --git a/launcher.sh b/launcher.sh index 0294a94..a8346aa 100755 --- a/launcher.sh +++ b/launcher.sh @@ -4,14 +4,31 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" cd "$DIR" -# Check if venv exists -if [ -d "$DIR/venv" ]; then - # Activate virtual environment +# Check if venv exists, create it if not +if [ ! -d "$DIR/venv" ]; then + echo "Virtual environment not found. Creating one..." + python3 -m venv "$DIR/venv" + + if [ $? -ne 0 ]; then + echo "Error: Failed to create virtual environment." + exit 1 + fi + + # Activate and install requirements source "$DIR/venv/bin/activate" - # Run the application - python3 fluxer-reaper.py "$@" + + if [ -f "$DIR/requirements.txt" ]; then + echo "Installing requirements..." + pip install --upgrade pip + pip install -r "$DIR/requirements.txt" + else + echo "Warning: requirements.txt not found. Skipping dependency installation." + fi else - echo "Error: Virtual environment not found in $DIR/venv" - echo "Please ensure you have installed the requirements into a 'venv' folder." - exit 1 + # Activate existing virtual environment + source "$DIR/venv/bin/activate" fi + +# Run the application +python3 fluxer-reaper.py "$@" + diff --git a/src/core/base.py b/src/core/base.py index 8c511f2..95e3c04 100644 --- a/src/core/base.py +++ b/src/core/base.py @@ -63,12 +63,22 @@ class MigrationContext: await self.fluxer_writer.start() async def close_connections(self): - await self.discord_reader.close() - await self.fluxer_writer.close() + try: + await self.discord_reader.close() + except Exception as e: + logger.debug(f"Error closing Discord reader: {e}") + try: + await self.fluxer_writer.close() + except Exception as e: + logger.debug(f"Error closing Fluxer writer: {e}") async def close_fluxer_only(self): """Closes only the Fluxer writer. Pair with start_fluxer_only().""" - await self.fluxer_writer.close() + try: + await self.fluxer_writer.close() + except Exception as e: + logger.debug(f"Error closing Fluxer writer: {e}") + def stop(self): self.is_running = False diff --git a/src/core/fluxer_writer.py b/src/core/fluxer_writer.py index 2863720..5e4144a 100644 --- a/src/core/fluxer_writer.py +++ b/src/core/fluxer_writer.py @@ -589,7 +589,11 @@ class FluxerWriter: async def close(self): """Cleanly close connection and stop bot task.""" if self.bot: - await self.bot.close() + try: + await self.bot.close() + except Exception as e: + logger.debug(f"Error closing Fluxer bot: {e}") + if self._bot_task: self._bot_task.cancel() try: @@ -598,3 +602,4 @@ class FluxerWriter: pass self._ready_event.clear() +