mirror of
https://github.com/coderofsalvation/podi.git
synced 2026-02-24 12:12:09 +01:00
41 lines
1.3 KiB
Plaintext
41 lines
1.3 KiB
Plaintext
# info: baremetal cli-template, perfect for outputting terminal-cmds to web
|
|
|
|
daemonize(){
|
|
while sleep 1s; do
|
|
set +e
|
|
./app
|
|
echo "$(tail -n200 app.log)" > app.log
|
|
done
|
|
}
|
|
|
|
stop(){
|
|
test -f .pid && { print "stopping $PODI_APP"; silent try kill -15 $(cat .pid); }
|
|
}
|
|
|
|
start(){
|
|
eval "$(cat .env)"
|
|
{ nohup ./podi daemonize $PODI_APP:$PORT 1> app.log 2> app.log; } &
|
|
echo $! > .pid
|
|
print "started $PODI_APP [PID $(cat .pid)] on $PODI_REMOTE:$PORT"
|
|
print "just try 'curl $PODI_REMOTE:$PORT' or use your browser"
|
|
}
|
|
|
|
init_runtime(){
|
|
test -f app || {
|
|
generate(){
|
|
echo '#!/bin/sh'
|
|
echo 'export JOB="cat hello.txt ; ls --color -la"'
|
|
echo 'which socat &>/dev/null || { echo "please install socat as root"; exit 1; }'
|
|
echo 'socat -t2 TCP4-LISTEN:$PORT,fork,max-children=3,forever,reuseaddr SYSTEM:"$JOB",pty,echo=0;'
|
|
}
|
|
generate > app
|
|
chmod 755 app
|
|
echo "HTTP/1.1 200\n\n H E L L O " > hello.txt
|
|
echo "export PORT=$(awk 'BEGIN{ srand(); print int(rand()*1000)+8000 }')" >> .env
|
|
git add app hello.txt .env .pod podi && git commit -m "adding podi"
|
|
}
|
|
test -f .pod/checkout/rollback_simple || recipe checkout/rollback_simple
|
|
test -f .pod/start/envfile || recipe start/envfile
|
|
test -f .pod/init/server/sshkey || recipe init/server/sshkey
|
|
}
|