tpsgi.sh 748 B

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