mirror of
https://github.com/coderofsalvation/podi.git
synced 2025-12-16 03:47:45 +01:00
recipe app/simple
This commit is contained in:
7
app/.pod/daemonize_simple
Normal file
7
app/.pod/daemonize_simple
Normal file
@@ -0,0 +1,7 @@
|
||||
daemonize(){
|
||||
while sleep 1s; do
|
||||
set +e
|
||||
${APP}
|
||||
echo "$(tail -n200 app.log)" > app.log
|
||||
done
|
||||
}
|
||||
30
app/.pod/envfile
Normal file
30
app/.pod/envfile
Normal file
@@ -0,0 +1,30 @@
|
||||
# info: sources environment variables from `.env` file during deployment
|
||||
# installation : run 'podi recipe env-file' or put this file into .podi folder
|
||||
# example usage: * put an .env file in your repo (with 'export FOO=1' e.g.)
|
||||
# * override them on remote-server using './podi .env git@server FOO=2'
|
||||
# * run './podi .env' to see all local/remote env-vars
|
||||
|
||||
envfile(){
|
||||
header .pod/envfile
|
||||
print "usage: ./podi envset [git@server] [app] [FOO=bar]"
|
||||
test -f .env && print "reading '.env'" && . .env
|
||||
test -f .env.live && print "override '.env' << .env.live" && . .env.live
|
||||
}
|
||||
|
||||
envset(){ # envset [git@server] [app] [FOO=bar] : shows or sets [remote] environment variables
|
||||
test -f .env || echo 'export FOO=bar # used for development' > .env
|
||||
if test -n "$3"; then
|
||||
loadremote $1 $2
|
||||
printf "export %-40s # $(date)\n" "$3\"" | awk '{ gsub("=","=\"",$0); print $0; }' | ssh -p $port $1 "cat >> $gitpath/.env.live"
|
||||
print OK
|
||||
else
|
||||
for app in .pod/*@*/*/config; do
|
||||
. $app
|
||||
print "$server:$appname (.env.live):"
|
||||
test -z $3 && ssh -p $port $user@$server "test -f $gitpath/.env.live && cat $gitpath/.env.live || echo ' no env-vars yet'"
|
||||
echo
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
on checkout envfile
|
||||
6
app/.pod/git@localhost/app5/config
Normal file
6
app/.pod/git@localhost/app5/config
Normal file
@@ -0,0 +1,6 @@
|
||||
export server='localhost'
|
||||
export port='2222'
|
||||
export user='git'
|
||||
export gitpath='/home/git/app5'
|
||||
export appname='app5'
|
||||
export branch='master'
|
||||
12
app/.pod/pipeline
Normal file
12
app/.pod/pipeline
Normal file
@@ -0,0 +1,12 @@
|
||||
deploy(){
|
||||
trigger hello
|
||||
trigger backup
|
||||
trigger checkout
|
||||
trigger build
|
||||
trigger runtests
|
||||
trigger start
|
||||
}
|
||||
|
||||
checkout(){
|
||||
git --work-tree=$(pwd) --git-dir=$(pwd)/.git checkout -f
|
||||
}
|
||||
24
app/.pod/simple
Normal file
24
app/.pod/simple
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
create_app_simple(){
|
||||
header ".pod/app_simple"
|
||||
test -f app || {
|
||||
print "writing app"
|
||||
echo 'echo "PID=$(cat .pid) => $(date) PORT=$PORT"' > app
|
||||
chmod 755 app
|
||||
print "writing .env"
|
||||
PORT=$(awk 'BEGIN{ srand(); print int(rand()*1000)+8000 }')
|
||||
echo 'export APP="./app"' > .env
|
||||
echo 'export PORT='$PORT >> .env
|
||||
}
|
||||
}
|
||||
|
||||
start(){
|
||||
. .env
|
||||
test -f .pid && { print "stopping app5"; silent try kill -15 $(cat .pid); }
|
||||
nohup ./podi daemonize ${APP} $PM_APP $PORT &> app.log &
|
||||
echo $! > .pid
|
||||
print "started: $APP [PID $(cat .pid)]"
|
||||
}
|
||||
|
||||
on init_localhost create_app_simple
|
||||
Reference in New Issue
Block a user