Skip to content

Commit

Permalink
feat: Code deploy- change profiles active
Browse files Browse the repository at this point in the history
  • Loading branch information
redcarrot1 committed Feb 4, 2024
1 parent adf9b92 commit 340b738
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/server-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ jobs:
echo "#### RUN $SOURCE_DIR/$FILE_NAME ####"
sudo nohup java -jar $SOURCE_DIR/$FILE_NAME -Dspring.profiles.active="dev" 1>$SOURCE_DIR/stdout.out 2>$SOURCE_DIR/stderr.out &
sudo nohup java -jar -Dspring.profiles.active="dev" $SOURCE_DIR/$FILE_NAME 1>$SOURCE_DIR/stdout.out 2>$SOURCE_DIR/stderr.out &
2 changes: 1 addition & 1 deletion src/main/java/solution/gdsc/PathPal/MainController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public TestResponse test(@RequestBody TestRequest testRequest) {

@GetMapping("/image/{imageId}")
@Operation(summary = "이미지 조회", description = "WebSocket으로 저장된 이미지를 조회합니다.(Content-Type: image/jpeg)")
public ResponseEntity<Resource> viewImg(@PathVariable(name = "imageId") Integer imageId) throws IOException {
public ResponseEntity<Resource> viewImg(@PathVariable(name = "imageId") String imageId) throws IOException {
final String fileFullPath = path + imageId + ".jpeg";
File file = new File(fileFullPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,20 @@ public class ClientInferenceController2 extends WebSocketClientController {
//@Value("${image.path}")
private String path = "/home/hsk4991149/static/image/";

private int imageId = 1;

@Override
public void afterConnectionEstablished(WebSocketSession session) {
Integer totalExpectedSeconds = parseTimeHeader(session);
if (totalExpectedSeconds == null) return;

Client client = new Client(totalExpectedSeconds);
clientRepository.save(client);

session.setBinaryMessageSizeLimit(1024 * 1024 * 10);
long currentTimeMillis = System.currentTimeMillis();
sessions.put(session, new SessionInfo(client, currentTimeMillis, totalExpectedSeconds));
}

private Integer parseTimeHeader(WebSocketSession session) {
List<String> time = session.getHandshakeHeaders().get("time");
if (time == null) {
System.err.println("time 헤더가 없습니다.");
Expand All @@ -50,7 +60,7 @@ public void afterConnectionEstablished(WebSocketSession session) {
session.close();
} catch (IOException e) {
}
return;
return null;
}
System.out.println("time 헤더: " + time.get(0));

Expand All @@ -64,15 +74,9 @@ public void afterConnectionEstablished(WebSocketSession session) {
session.close();
} catch (IOException e1) {
}
return;
return null;
}

Client client = new Client(totalExpectedSeconds);
clientRepository.save(client);

session.setBinaryMessageSizeLimit(1024 * 1024 * 10);
long currentTimeMillis = System.currentTimeMillis();
sessions.put(session, new SessionInfo(client, currentTimeMillis, totalExpectedSeconds));
return totalExpectedSeconds;
}

@Override
Expand Down Expand Up @@ -113,9 +117,7 @@ protected void handleBinaryMessage(WebSocketSession session, BinaryMessage messa
SessionInfo sessionInfo = sessions.get(session);
if (currentTimeMillis - sessionInfo.recentlySaveTime > savePeriodMilliSeconds) {

//String fileFullName = path + sessionInfo.getClient().getId() + "T" + currentTimeMillis + ".jpeg";
String fileFullName = path + imageId;
imageId++;
String fileFullName = path + sessionInfo.getClient().getId() + "T" + currentTimeMillis + ".jpeg";
try (FileImageOutputStream imageOutput = new FileImageOutputStream(new File(fileFullName))) {
imageOutput.write(bytes, 0, bytes.length);

Expand Down

0 comments on commit 340b738

Please sign in to comment.