You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.4 KiB
60 lines
2.4 KiB
Your script appears to be a set of commands intended to be run by the "swarms" user. It sets up an environment, installs dependencies, and prepares to launch a service. Here are some suggestions to improve and enhance the script:
|
|
|
|
1. **Add Error Handling:**
|
|
- Implement error handling mechanisms with appropriate exits and messages to handle failures gracefully.
|
|
|
|
2. **Use Absolute Paths:**
|
|
- Prefer using absolute paths instead of relative paths to avoid any ambiguity.
|
|
|
|
3. **Add Logging:**
|
|
- Incorporate logging statements to track the progress and potential issues during script execution.
|
|
|
|
4. **Documentation:**
|
|
- Include comments to explain each step and document the purpose of the script and individual commands.
|
|
|
|
5. **Finalize Service Launch:**
|
|
- Ensure to start the required service once the dependencies are installed and configurations are completed.
|
|
|
|
Here's an enhanced version of your script incorporating these suggestions:
|
|
|
|
```bash
|
|
#!/bin/bash
|
|
set -e
|
|
set -x
|
|
|
|
# Set environment variables
|
|
export ROOT="/mnt/data1/swarms"
|
|
export HOME="${ROOT}/home/swarms"
|
|
unset CONDA_EXE
|
|
unset CONDA_PYTHON_EXE
|
|
export PATH="${ROOT}/var/swarms/agent_workspace/.venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
|
|
|
# Activate virtual environment
|
|
if [ ! -f "${ROOT}/var/swarms/agent_workspace/.venv/" ]; then
|
|
virtualenv "${ROOT}/var/swarms/agent_workspace/.venv/"
|
|
fi
|
|
|
|
source "${ROOT}/var/swarms/agent_workspace/.venv/bin/activate"
|
|
|
|
# Install dependencies
|
|
pip install fastapi uvicorn termcolor
|
|
pip install -e "${ROOT}/opt/swarms/"
|
|
cd "${ROOT}/var/swarms/"
|
|
pip install -e "${ROOT}/opt/swarms-memory"
|
|
pip install "fastapi[standard]" "loguru" pydantic==2.8.2
|
|
|
|
# Verify installation
|
|
#pip freeze
|
|
|
|
# Launch your service (Uncomment and add your starting command)
|
|
#python /opt/swarms/api/main.py
|
|
|
|
# Start your service as a systemd service
|
|
# You can add the relevant service configuration and enable it here
|
|
```
|
|
|
|
Make sure to uncomment and add the necessary command for starting your service. Additionally, continue the script with the configuration and setup required to launch the service, such as creating a systemd service unit file and enabling the service.
|
|
|
|
Please adapt this script according to your specific service requirements, and ensure you have the necessary permissions and environment configurations to run the script successfully.
|
|
mdupont@mdupont-G470:~/2024/05/swarms/api$
|