Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heroku config #2

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir> <env-dir>

# used for inline heroku buildpack

BUILD_DIR=${1:-}
CACHE_DIR=${2:-}
ENV_DIR=${3:-}

PROJECT_PATH=controller/src/main/python

echo "-----> My Subdir buildpack: path is $PROJECT_PATH"
echo " creating cache: $CACHE_DIR"
mkdir -p $CACHE_DIR
TMP_DIR=`mktemp -d $CACHE_DIR/subdirXXXXX`
echo " created tmp dir: $TMP_DIR"

echo " moving working dir: $PROJECT_PATH to $TMP_DIR"
cp -R $BUILD_DIR/$PROJECT_PATH/. $TMP_DIR/

echo " cleaning build dir $BUILD_DIR"
rm -rf $BUILD_DIR
echo " recreating $BUILD_DIR"
mkdir -p $BUILD_DIR
echo " copying work dir from cache $TMP_DIR to build dir $BUILD_DIR"
cp -R $TMP_DIR/. $BUILD_DIR/
echo " cleaning tmp dir $TMP_DIR"
rm -rf $TMP_DIR
exit 0
7 changes: 7 additions & 0 deletions bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# bin/detect <build-dir>

# used for inline heroku buildpack

echo "My Subdir buildpack"
exit 0
5 changes: 5 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

# used for inline heroku buildpack

echo "--- {}"
1 change: 1 addition & 0 deletions controller/src/main/python/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn -w 1 server:app
1 change: 1 addition & 0 deletions controller/src/main/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
simple-websocket-server==0.4.1
1 change: 1 addition & 0 deletions controller/src/main/python/runtime.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-3.8.10
4 changes: 2 additions & 2 deletions controller/src/main/python/server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from simple_websocket_server import WebSocketServer, WebSocket


class SimpleChat(WebSocket):
def handle(self):
for client in clients:
Expand All @@ -23,5 +23,5 @@ def handle_close(self):

clients = []

server = WebSocketServer('', 8000, SimpleChat)
server = WebSocketServer('0.0.0.0', os.environ.get('PORT', '8000'), SimpleChat)
server.serve_forever()
2 changes: 1 addition & 1 deletion controller/src/main/www/camera_joystick.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1 style="text-align:center; display: none;">
</p>
<canvas id="canvas" name="game"></canvas>
<script>
var connection = new WebSocket('ws://' + "localhost" + ':8000/');
var connection = new WebSocket('wss://' + "cara-bot.herokuapp.com" + '/0.0.0.0');
connection.onopen = function () {
connection.send('Connect ' + new Date());
};
Expand Down
2 changes: 1 addition & 1 deletion projection/src/main/python/eye.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def run(*args):

if __name__ == "__main__":
# websocket.enableTrace(True)
ws = websocket.WebSocketApp("ws://192.168.66.137:8000/",
ws = websocket.WebSocketApp("ws://cara-bot.herokuapp.com:8000/",
# ws = websocket.WebSocketApp("ws://echo.websocket.org/",
on_open=on_open,
on_message=on_message,
Expand Down