Skip to content

Commit b0da66c

Browse files
committed
Merge remote-tracking branch 'origin/master' into bhcs/add-serverless-logic
2 parents 26deb1d + df0eb63 commit b0da66c

File tree

12 files changed

+44
-51
lines changed

12 files changed

+44
-51
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ A set of email/password with admin privileges will be uploaded to Canvas through
66

77
# Testing Locally
88

9-
## DISCLAIMER: Our executor service can only run on x86_64 architecture. If you are using a different architecture, you will not be able to run the executor locally. However, you can still test the rest of the application.
10-
119
- Install Docker for your operating system. You can find the installation instructions [here](https://docs.docker.com/get-docker/).
1210
- Clone the repository.
1311
- Run `git submodule update --init` to clone the submodules.

deployment/Dockerfile-executor

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# docker build -f deployment/Dockerfile-executor -t peerprep-executor .
44

5-
FROM nixos/nix:2.3.12
5+
FROM opensuse/tumbleweed
66

77
# Environment variables
88

@@ -11,13 +11,17 @@ ENV APP_ROOT /executor
1111
WORKDIR $APP_ROOT
1212
COPY executor .
1313

14-
RUN nix-channel --update
15-
RUN nix-env -iA nixpkgs.shadow nixpkgs.gcc12 nixpkgs.python3Minimal nixpkgs.jdk19_headless
16-
RUN nix-env -if default.nix
14+
RUN groupadd -g 1300 -r peerprep && useradd -g 1300 -u 1500 -r executor
1715

18-
RUN groupadd -g 1300 -r peerprep
19-
RUN useradd -g 1300 -u 1500 -r executor
16+
RUN zypper refresh
17+
RUN zypper install -t pattern -y devel_C_C++
18+
RUN zypper install -y cmake
19+
RUN zypper install -y java-11-openjdk-devel
20+
21+
RUN cmake -DCMAKE_BUILD_TYPE=Release -S . -B ./build
22+
RUN cmake --build ./build --config Release
23+
RUN cp ./build/executor ./executor
2024

2125
EXPOSE 9000
2226

23-
CMD ["executor"]
27+
CMD ["./executor"]

docker-compose.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ services:
2727
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
2828

2929
executor:
30-
image: ghcr.io/peerprep/peerprep-executor-service:latest
30+
image: peerprep-executor-service
31+
build:
32+
context: .
33+
dockerfile: deployment/Dockerfile-executor
3134
container_name: peerprep-executor-service
3235
restart: always
3336
networks:
@@ -50,6 +53,7 @@ services:
5053
- ./firebase-auth:/firebase-auth
5154
environment:
5255
GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS}
56+
LOGGING: "VERBOSE"
5357

5458
questions:
5559
image: peerprep-questions-service

executor/default.nix

Lines changed: 0 additions & 19 deletions
This file was deleted.

frontend/src/app/components/code-editor/CodeEditor.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import * as Y from "yjs";
1717
import Tabs from "../tab/Tabs";
1818
import { fetchProfileUrl } from "@/app/api";
1919

20+
import { BsArrowsExpand } from "react-icons/bs";
21+
2022
const CodeMirror = dynamic(() => import("@uiw/react-codemirror"), {
2123
ssr: false,
2224
loading: () => (
@@ -208,9 +210,11 @@ const CodeMirrorEditor = ({
208210
}}
209211
/>
210212
<div
211-
className="divider mx-auto w-[90svw] cursor-ns-resize lg:w-full"
213+
className="divider mx-auto w-[90svw] cursor-ns-resize hover:bg-accent lg:w-full"
212214
onMouseDown={handleMouseDown}
213-
/>
215+
>
216+
<BsArrowsExpand className="text-state-100 text-4xl" />
217+
</div>
214218
<Tabs
215219
height={Math.min(window.innerHeight * 0.7 - editorHeight, maxHeight)}
216220
/>

frontend/src/app/components/status-bar/StatusBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const StatusBar = ({ exitMethod }: StatusBarProps) => {
6363
};
6464

6565
return (
66-
<footer className="fixed bottom-0 left-0 flex w-[100svw] items-center justify-between border-black bg-primary px-4 py-2 shadow-sm lg:static lg:w-full lg:px-12">
66+
<footer className="fixed bottom-0 left-0 flex w-[100svw] items-center justify-between border-black bg-primary px-4 py-2 shadow-sm lg:w-full lg:px-12">
6767
{contextHolder}
6868
<div className="flex gap-4">
6969
{userStates &&

innkeeper/src/controllers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import { SHOULD_LOG } from '../utils';
33

44
export const sendNotification = (socket: InnkeeperIoSocket | InnkeeperOtherSockets, { type, message }: NotificationMessage) => {
55
const socketData = `${socket.id} (userId: ${socket.data.userId})`;
6-
SHOULD_LOG && console.log(`Sending ${type} notification to ${socketData}: ${message}`);
6+
SHOULD_LOG && console.log(`[OTHER][NOTIF] Sending ${type} notification to ${socketData}: ${message}`);
77
socket.emit('sendNotification', { type, message });
88
};

innkeeper/src/controllers/lobby.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const notifyOnQueue = (io: InnkeeperIoServer, inn: InnState, socket: InnkeeperIo
2323
};
2424

2525
export const handleConnect = (io: InnkeeperIoServer, inn: InnState, socket: InnkeeperIoSocket): void => {
26-
SHOULD_LOG && console.log(`User ${socket.data?.userId} connected to lobby.`);
26+
SHOULD_LOG && console.log(`[LOBBY][Q] User ${socket.data?.userId} connected to lobby.`);
2727
const waitingUsers = inn.getWaitingUsers();
2828
socket.join('lobby');
2929
socket.emit('availableMatches', waitingUsers);
@@ -38,20 +38,20 @@ export const handleMatchingRequest = (
3838
socket.data.lastMessage = getUnixTimestamp();
3939
const { userId, displayName, imageUrl } = socket.data;
4040

41-
SHOULD_LOG && console.log(`User ${displayName} (${userId}) requested a match with parameters ${JSON.stringify(params)}.`);
41+
SHOULD_LOG && console.log(`[LOBBY][Q] User ${displayName} (${userId}) requested a match with parameters ${JSON.stringify(params)}.`);
4242

4343
// Remove user from queue in case this is a re-request.
4444
inn.removeUserFromQueue({ userId, displayName, imageUrl });
4545

4646
const maybeMatch = inn.queueUserOrReturnMatchResult({ userId, displayName, imageUrl }, params);
4747
if (!maybeMatch) {
4848
notifyOnQueue(io, inn, socket);
49-
SHOULD_LOG && console.log(`User ${userId} added to queue.`);
49+
SHOULD_LOG && console.log(`[LOBBY][Q] User ${userId} added to queue.`);
5050
return;
5151
}
5252

5353
const [otherUserId, roomState] = maybeMatch;
54-
SHOULD_LOG && console.log(`Matched users ${userId} and ${otherUserId} in room ${roomState.roomId}.`);
54+
SHOULD_LOG && console.log(`[LOBBY][Q] Matched users ${userId} and ${otherUserId} in room ${roomState.roomId}.`);
5555

5656
io.in('lobby')
5757
.fetchSockets()
@@ -67,12 +67,12 @@ export const handleMatchingRequest = (
6767
otherSocket.data.roomId = roomState.roomId;
6868
otherSocket.emit('sendToRoom', roomState.roomId);
6969
joinAssignedRoom(io, inn, otherSocket);
70-
SHOULD_LOG && console.log(`Sent users ${userId} and ${otherUserId.userId} to room ${roomState.roomId}.`);
70+
SHOULD_LOG && console.log(`[LOBBY][Q] Sent users ${userId} and ${otherUserId.userId} to room ${roomState.roomId}.`);
7171
return;
7272
}
7373

7474
// socket with matching otherUserId could not be found, remove from queue.
75-
console.error(`Could not find socket for userId ${otherUserId} (returned from queue).`);
75+
console.error(`[LOBBY][Q] Could not find socket for userId ${otherUserId} (returned from queue).`);
7676
inn.removeUserFromQueue(otherUserId);
7777

7878
inn.addUserToQueue({ userId, displayName, imageUrl }, params);
@@ -84,5 +84,5 @@ export const handleDisconnect = (io: InnkeeperIoServer, inn: InnState, socket: I
8484
const { userId, displayName, imageUrl } = socket.data;
8585
inn.removeUserFromQueue({ userId, displayName, imageUrl });
8686

87-
SHOULD_LOG && console.log(`User ${userId} disconnected from queue.`);
87+
SHOULD_LOG && console.log(`[LOBBY][Q] User ${userId} disconnected from queue.`);
8888
};

innkeeper/src/controllers/room.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import { getUnixTimestamp } from '../utils';
66
export const getRoomState = (inn: InnState, socket: InnkeeperIoSocket | InnkeeperOtherSockets): RoomState | undefined => {
77
const { roomId } = socket.data;
88
if (!roomId) {
9-
console.error(`Unexpected undefined roomId for socket ${socket.id}. Data: ${socket.data}.`);
9+
console.error(`[ROOM][ERR] Unexpected undefined roomId for socket ${socket.id}. Data: ${socket.data}.`);
1010
return undefined;
1111
}
1212

1313
const roomState = inn.getRoomState(roomId);
1414
if (!roomState) {
15-
console.error(`Unexpected undefined roomState for socket ${socket.id}. Data: ${socket.data}.`);
15+
console.error(`[ROOM][ERR] Unexpected undefined roomState for socket ${socket.id}. Data: ${socket.data}.`);
1616
return undefined;
1717
}
1818

@@ -24,7 +24,7 @@ const getSelfAndOtherUser = (room: RoomState, userId: string): [UserState, UserS
2424
const userState = userStates.find(s => s.userId === userId);
2525
const otherUserState = userStates.find(s => s.userId !== userId);
2626
if (!userState || !otherUserState) {
27-
console.error(`Unexpected user states in ${room.roomId}: ${userStates} (asking for ${userId} & roommate).`);
27+
console.error(`[ROOM][ERR] Unexpected user states in ${room.roomId}: ${userStates} (asking for ${userId} & roommate).`);
2828
return undefined;
2929
}
3030

@@ -195,7 +195,6 @@ export const handleChatMessage = (io: InnkeeperIoServer, inn: InnState, socket:
195195
roomState.chatHistory = [];
196196
}
197197
roomState.chatHistory.push(chatMessage);
198-
console.log(roomState.chatHistory);
199198

200199
// Emit the chat message to all users in the room
201200
io.to(roomState.roomId).emit('sendPartialRoomState', { chatHistory: roomState.chatHistory });

innkeeper/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ const ysocketio = new YS.YSocketIO(io, {
6565
gcEnabled: false,
6666
});
6767

68-
ysocketio.on('document-loaded', (doc: any) => SHOULD_LOG && console.log(`The document ${doc.name} was loaded`));
69-
ysocketio.on('document-update', (doc: any, update: Uint8Array) => SHOULD_LOG && console.log(`The document ${doc.name} is updated`));
68+
ysocketio.on('document-loaded', (doc: any) => SHOULD_LOG && console.log(`[ROOM][YDOC] The document ${doc.name} was loaded`));
69+
ysocketio.on(
70+
'document-update',
71+
(doc: any, update: Uint8Array) => SHOULD_LOG && console.log(`[ROOM][YDOC] The document ${doc.name} is updated`),
72+
);
7073
ysocketio.on('awareness-update', (doc: any, update: Uint8Array) => {
7174
// SHOULD_LOG && console.log(`The awareness of the document ${doc.name} is updated`),
7275
});
73-
ysocketio.on('document-destroy', async (doc: any) => SHOULD_LOG && console.log(`The document ${doc.name} is being destroyed`));
76+
ysocketio.on('document-destroy', async (doc: any) => SHOULD_LOG && console.log(`[ROOM][YDOC] The document ${doc.name} is being destroyed`));
7477
ysocketio.on(
7578
'all-document-connections-closed',
76-
async (doc: any) => SHOULD_LOG && console.log(`All clients of document ${doc.name} are disconnected`),
79+
async (doc: any) => SHOULD_LOG && console.log(`[ROOM][YDOC] All clients of document ${doc.name} are disconnected`),
7780
);
7881

7982
// Execute initialize method

0 commit comments

Comments
 (0)