tpsgi.sh 894 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. HOMEDIR=$(git rev-parse --show-toplevel)
  3. [[ ! -z $HOMEDIR ]] && HOME=$HOMEDIR
  4. echo "Set HOME to $HOME"
  5. cd $HOME
  6. echo "Changed directory to $HOME"
  7. # Make sure this is referring to the right perl env
  8. source .bashrc
  9. USERNAME=$(bin/tpsgi-config --user)
  10. [[ -z $USERNAME ]] && USERNAME=$USER
  11. echo "tPSGI running as user $USERNAME"
  12. [[ -e run/tpsgi.pid ]] && sudo pkill -F run/tpsgi.pid
  13. # We should obey the PATH set by this user, whose homedir is right here, ideally.
  14. bin/tpsgi --listen run/tpsgi.sock --workers 20 --user "$USERNAME" --daemonize --pid run/tpsgi.pid --chroot $(pwd)
  15. # Wait until the socket file is ready
  16. until [ -e run/tpsgi.sock ]
  17. do
  18. echo "Waiting for sock to be ready..."
  19. sleep 1
  20. done
  21. # Fix ownership of socket so nginx can see it
  22. sudo chown $USERNAME:www-data run/tpsgi.sock
  23. sudo chmod 0770 run/tpsgi.sock
  24. echo "tPSGI running as PID "`cat run/tpsgi.pid`