@ -3,8 +3,9 @@
. ./.env # for secrets
. ./.env # for secrets
set -e # stop on any error
set -e # stop on any error
set -x
set -x
export BRANCH = "feature/ec2"
export ROOT = "/mnt/data1/swarms"
#export ROOT="/mnt/data1/swarms"
export ROOT = "" # empty
export WORKSOURCE = " ${ ROOT } /opt/swarms/api "
export WORKSOURCE = " ${ ROOT } /opt/swarms/api "
if [ ! -d " ${ ROOT } /opt/swarms/install/ " ] ; then
if [ ! -d " ${ ROOT } /opt/swarms/install/ " ] ; then
@ -12,14 +13,16 @@ if [ ! -d "${ROOT}/opt/swarms/install/" ]; then
fi
fi
if [ ! -f " ${ ROOT } /opt/swarms/install/apt.txt " ] ; then
if [ ! -f " ${ ROOT } /opt/swarms/install/apt.txt " ] ; then
sudo apt update
apt update
sudo apt install --allow-change-held-packages -y git virtualenv
apt install --allow-change-held-packages -y git virtualenv nginx expect
snap install aws-cli --classic
echo 1 >" ${ ROOT } /opt/swarms/install/apt.txt "
echo 1 >" ${ ROOT } /opt/swarms/install/apt.txt "
fi
fi
if [ ! -f " ${ ROOT } /opt/swarms/install/setup.txt " ] ; then
if [ ! -f " ${ ROOT } /opt/swarms/install/setup.txt " ] ; then
#rm -rf ./src/swarms # oops
#rm -rf ./src/swarms # oops
adduser swarms --home " ${ ROOT } /home/swarms " || echo ignore
#adduser --disabled-password --comment "" swarms --home "${ROOT}/home/swarms" || echo ignore
adduser --disabled-password --gecos "" swarms --home " ${ ROOT } /home/swarms " || echo ignore
git config --global --add safe.directory " ${ ROOT } /opt/swarms "
git config --global --add safe.directory " ${ ROOT } /opt/swarms "
git config --global --add safe.directory " ${ ROOT } /opt/swarms-memory "
git config --global --add safe.directory " ${ ROOT } /opt/swarms-memory "
# we should have done this
# we should have done this
@ -27,12 +30,13 @@ if [ ! -f "${ROOT}/opt/swarms/install/setup.txt" ]; then
then
then
git clone https://github.com/jmikedupont2/swarms " ${ ROOT } /opt/swarms/ "
git clone https://github.com/jmikedupont2/swarms " ${ ROOT } /opt/swarms/ "
fi
fi
pushd " ${ ROOT } /opt/swarms/ " || exit 1 # "we need swarms"
cd " ${ ROOT } /opt/swarms/ " || exit 1 # "we need swarms"
git remote add local /time/2024/05/swarms/ || git remote set-url local /time/2024/05/swarms/
# git remote add local /time/2024/05/swarms/ || git remote set-url local /time/2024/05/swarms/
git fetch local
# git fetch local
git checkout feature/ec2 # switch branches
# git stash
git pull local feature/ec2
git checkout --force $BRANCH
popd || exit 2
git pull
git log -2 --patch | head -1000
if [ ! -d " ${ ROOT } /opt/swarms-memory/ " ] ;
if [ ! -d " ${ ROOT } /opt/swarms-memory/ " ] ;
then
then
git clone https://github.com/The-Swarm-Corporation/swarms-memory " ${ ROOT } /opt/swarms-memory "
git clone https://github.com/The-Swarm-Corporation/swarms-memory " ${ ROOT } /opt/swarms-memory "
@ -65,65 +69,54 @@ fi
## pull
## pull
if [ ! -f " ${ ROOT } /opt/swarms/install/pull.txt " ] ; then
if [ ! -f " ${ ROOT } /opt/swarms/install/pull.txt " ] ; then
push d " ${ ROOT } /opt/swarms/ " || exit 1 # "we need swarms"
c d " ${ ROOT } /opt/swarms/ " || exit 1 # "we need swarms"
git fetch local
# git fetch local
git checkout feature/ec2 # switch branches
# git stash
git pull local feature/ec2
git checkout --force $BRANCH
popd || exit 2
git pull # $BRANCH
#echo 1 >"${ROOT}/opt/swarms/install/pull.txt "
echo 1 >" ${ ROOT } /opt/swarms/install/pull.txt "
fi
fi
if [ ! -f " ${ ROOT } /opt/swarms/install/config.txt " ] ; then
if [ ! -f " ${ ROOT } /opt/swarms/install/config.txt " ] ; then
#WorkingDirectory=ROOT/var/run/swarms/
# create the secrets
mkdir -p " ${ ROOT } /var/run/swarms/secrets/ "
mkdir -p " ${ ROOT } /var/run/swarms/secrets/ "
echo " OPENAI_KEY= ${ OPENAI_KEY } " > " ${ ROOT } /var/run/swarms/secrets/env "
# cache
mkdir -p " ${ ROOT } /home/swarms/.cache/huggingface/hub "
mkdir -p " ${ ROOT } /home/swarms/.cache/huggingface/hub "
# aws ssm get-parameter --name "swarms_openai_key" > /root/openaikey.txt
export OPENAI_KEY = ` aws ssm get-parameter --name "swarms_openai_key" | jq .Parameter.Value -r `
echo " OPENAI_KEY= ${ OPENAI_KEY } " > " ${ ROOT } /var/run/swarms/secrets/env "
## append new homedir
## append new homedir
echo " TRANSFORMERS_CACHE= ${ ROOT } /home/swarms/.cache/huggingface/hub " >> " ${ ROOT } /var/run/swarms/secrets/env "
echo " HF_HOM E=${ ROOT } /home/swarms/.cache/huggingface/hub " >> " ${ ROOT } /var/run/swarms/secrets/env "
echo " HOME= ${ ROOT } /home/swarms " >> " ${ ROOT } /var/run/swarms/secrets/env "
echo " HOME= ${ ROOT } /home/swarms " >> " ${ ROOT } /var/run/swarms/secrets/env "
# attempt to move the workspace
echo 'WORKSPACE_DIR=${STATE_DIRECTORY}' >> " ${ ROOT } /var/run/swarms/secrets/env "
#EnvironmentFile=ROOT/var/run/swarms/secrets/env
#EnvironmentFile=ROOT/var/run/swarms/secrets/env
#ExecStart=ROOT/var/run/uvicorn/env/bin/uvicorn \
#ExecStart=ROOT/var/run/uvicorn/env/bin/uvicorn \
# --uds ROOT/run/uvicorn/uvicorn-swarms-api.sock \
# --uds ROOT/run/uvicorn/uvicorn-swarms-api.sock \
echo 1 >" ${ ROOT } /opt/swarms/install/config.txt "
echo 1 >" ${ ROOT } /opt/swarms/install/config.txt "
fi
fi
# if [ ! -f "${ROOT}/opt/swarms/install/uvicorn.txt" ]; then
# # we create a second installation of unicorn so agents cannot mess it up.
# mkdir -p "${ROOT}/var/run/uvicorn/env/"
# if [ ! -f "${ROOT}/var/run/uvicorn/env/" ];
# then
# virtualenv "${ROOT}/var/run/uvicorn/env/"
# fi
# . "${ROOT}/var/run/uvicorn/env/bin/activate"
# pip install uvicorn
# echo 1 >"${ROOT}/opt/swarms/install/uvicorn.txt"
# fi
if [ ! -f " ${ ROOT } /opt/swarms/install/nginx.txt " ] ; then
if [ ! -f " ${ ROOT } /opt/swarms/install/nginx.txt " ] ; then
mkdir -p ${ ROOT } /var/log/nginx/swarms/
mkdir -p ${ ROOT } /var/log/nginx/swarms/
fi
fi
# reconfigure
# now we setup the service and replace root in the files
#echo cat "${WORKSOURCE}/nginx/site.conf" \| sed -e "s!ROOT!${ROOT}!g"
cat " ${ WORKSOURCE } /nginx/site.conf " | sed -e " s!ROOT! ${ ROOT } !g " > /etc/nginx/sites-enabled/default
#cat /etc/nginx/sites-enabled/default
# create sock
# create sock
mkdir -p ${ ROOT } /run/uvicorn/
mkdir -p ${ ROOT } /run/uvicorn/
chown -R swarms:swarms ${ ROOT } /run/uvicorn
chown -R swarms:swarms ${ ROOT } /run/uvicorn
# reconfigure
# now we setup the service and replace root in the files
#echo cat "${WORKSOURCE}/nginx/site.conf" \| sed -e "s!ROOT!${ROOT}!g"
sed -e " s!ROOT! ${ ROOT } !g " > /etc/nginx/sites-enabled/default < " ${ WORKSOURCE } /nginx/site.conf "
#cat /etc/nginx/sites-enabled/default
# ROOT/var/run/swarms/uvicorn-swarms-api.sock;
# ROOT/var/run/swarms/uvicorn-swarms-api.sock;
# access_log ROOT/var/log/nginx/swarms/access.log;
# access_log ROOT/var/log/nginx/swarms/access.log;
# error_log ROOT/var/log/nginx/swarms/error.log;
# error_log ROOT/var/log/nginx/swarms/error.log;
#echo cat "${WORKSOURCE}/systemd/uvicorn.service" \| sed -e "s!ROOT!/${ROOT}/!g"
#echo cat "${WORKSOURCE}/systemd/uvicorn.service" \| sed -e "s!ROOT!/${ROOT}/!g"
cat " ${ WORKSOURCE } /systemd/uvicorn.service " | sed -e " s!ROOT! ${ ROOT } !g " > /etc/systemd/system/swarms-uvicorn.service
#cat "${WORKSOURCE}/systemd/uvicorn.service"
sed -e " s!ROOT! ${ ROOT } !g " > /etc/systemd/system/swarms-uvicorn.service < " ${ WORKSOURCE } /systemd/uvicorn.service "
grep . -h -n /etc/systemd/system/swarms-uvicorn.service
# if [ -f ${ROOT}/etc/systemd/system/swarms-uvicorn.service ];
# if [ -f ${ROOT}/etc/systemd/system/swarms-uvicorn.service ];
# then
# then
@ -139,14 +132,25 @@ cat "${WORKSOURCE}/systemd/uvicorn.service" | sed -e "s!ROOT!${ROOT}!g" > /etc/s
#/run/uvicorn/
#/run/uvicorn/
# triage
# triage
chown -R swarms:swarms ${ ROOT } /var/run/swarms/
chown -R swarms:swarms ${ ROOT } /var/run/swarms/
# Dec 12 10:55:50 mdupont-G470 unbuffer[3921723]: OSError: [Errno 30] Read-only file system:
#cat /etc/systemd/system/swarms-uvicorn.service
# now fix the perms
mkdir -p ${ ROOT } /opt/swarms/api/agent_workspace/try_except_wrapper/
chown -R swarms:swarms ${ ROOT } /opt/swarms/api/
#cat /etc/systemd/system/swarms-uvicorn.service
# always reload
# always reload
systemctl daemon-reload
systemctl daemon-reload
# systemctl start swarms-uvicorn || systemctl status swarms-uvicorn.service && journalctl -xeu swarms-uvicorn.service
# systemctl start swarms-uvicorn || systemctl status swarms-uvicorn.service && journalctl -xeu swarms-uvicorn.service
systemctl start swarms-uvicorn || journalctl -xeu swarms-uvicorn.service
systemctl start swarms-uvicorn || journalctl -xeu swarms-uvicorn.service
# systemctl status swarms-uvicorn.service
# systemctl status swarms-uvicorn.service
# journalctl -xeu swarms-uvicorn.service
# journalctl -xeu swarms-uvicorn.service o
systemctl enable swarms-uvicorn || journalctl -xeu swarms-uvicorn.service
systemctl enable swarms-uvicorn || journalctl -xeu swarms-uvicorn.service
service nginx restart
systemctl enable nginx
systemctl start nginx
journalctl -xeu swarms-uvicorn.service | tail -200 || echo oops
systemctl status swarms-uvicorn.service || echo oops2
# mikes tools
apt install -y emacs-nox tmux