jirheee / CS492-Team-Project

CS492-Team-Project
MIT License
1 stars 2 forks source link

"Server" Questions #8

Closed Mins0o closed 2 years ago

Mins0o commented 2 years ago

Questions regarding developing and running the "Server".

jirheee commented 2 years ago

Wassup

Mins0o commented 2 years ago

image

I ran

$env:DB_USERNAME="Minsoo" 
$env:DB_ROOT_PASSWORD="password" 
$env:DB_PASSWORD="password_" 
$env:MAINDB_NAME="Minsoo"

and
docker-compose -f docker-compose.yml up in my Windows Powershell, and seems like the cs492i-api-server is having some troubles. Is this a problem?

Mins0o commented 2 years ago
$env:DB_USERNAME="Minsoo" 
$env:DB_ROOT_PASSWORD="password" 
$env:DB_PASSWORD="password_" 
$env:MAINDB_NAME="Minsoo"

Ah I realized there is env.example file.

jirheee commented 2 years ago

You should run cp .env.example .env first to create .env file!

Mins0o commented 2 years ago

Will I still need to follow the README.md?

pip install fastapi
pip install 'uvicorn[standard]'
pip install python-socketio

uvicorn main:socketio_app --reload

jirheee commented 2 years ago

Nope it's from the python boilerplate code. I will update the README ASAP

jirheee commented 2 years ago

Oh so I didn't update the README. to run the server, you can just use docker-compose up command. You have nothing to configure manually now. Sorry for the inconvenience.

Mins0o commented 2 years ago

You should run cp .env.example .env first to create .env file!

Still when I run docker-compose -f docker-compose.yml up, I get the error as:

cs492i-api-server  | standard_init_linux.go:228: exec user process caused: no such file or directory
cs492i-api-server exited with code 0
cs492i-api-server exited with code 1
cs492i-api-server exited with code 1
cs492i-api-server exited with code 1
...
...
jirheee commented 2 years ago

What branch are you at currently?

Mins0o commented 2 years ago

main. Should I run yarn start first?

jirheee commented 2 years ago

Can you post a screenshot of your local server directory?

jirheee commented 2 years ago

Well I guess yarn is not the problem since it runs yarn start at entrypoint.sh

Mins0o commented 2 years ago

Can you post a screenshot of your local server directory?

image

jirheee commented 2 years ago

I think you should try with this command docker-compose up --build

jirheee commented 2 years ago

I think the .env file is not in the built image happened because you build the container before making .env file

Mins0o commented 2 years ago

I think you should try with this command docker-compose up --build

Still no luck :(

Mins0o commented 2 years ago

I detached the volume and re-ran the docker-compose up --build.
I have more info with the "initial run" now... let me get back to you later!

Thanks for the help.

Mins0o commented 2 years ago

I have one volume present, is this normal? image

Mins0o commented 2 years ago

I got it successfully running on my Linux machine, which is very very slow. I'll figure out how I can run this on my own machine later

jirheee commented 2 years ago

I have one volume present, is this normal?

There should be one volume, one used by the mysql container. So I think it's right. Can you show me the error log it prints out?

Mins0o commented 2 years ago

Ahrrraaggggghhhhhhghghhhh I found out what was causing the problem.

The error: standard_init_linux.go:228: exec user process caused: no such file or directory

Turns out, Windows and Linux has different line ending scheme. IT WAS LITERALLY A BUG THAT IS INVISIBLE TO NAKED EYES.

DOS uses carriage return and line feed ("\r\n") as a line ending, which Unix uses just line feed ("\n")

You can easily fix the influenced file in VSCode.

Or change your git settings where it automatically converted all the \n to \r\n. 😠 💢

There must be a way for Docker Desktop to make this transition automatic when copying .sh from a Windows environment into a Linux container @docker ...

jirheee commented 2 years ago

Oh so the entrypoint.sh is copied into docker image with carriage return("\r\n")...? Or is "\n" being converted into "\r\n" at git pulling stage?

Mins0o commented 2 years ago

This has bug.
image


This is fixed.
image

The fix: image => image

Mins0o commented 2 years ago

Oh so the entrypoint.sh is copied into docker image with carriage return("\r\n")...? Or is "\n" being converted into "\r\n" at git pulling stage?

At the git pulling stage.

I wrote my rant over it hoping to help another poor souls who might suffer from it lol 😆 Oh there were many others including this guy😅, but to be fair, I wouldn't have known which file they were talking about.

jirheee commented 2 years ago

I hate this kind of implicit things happening out of user's perception 🥲 It is almost impossible to debug things if you don't know that can actually happen... I think @dbsxodud-11 should refer to this issue if there is something awkward happening while running the server. Can you edit the README file in server directory for @dbsxodud-11 to refer to?

Mins0o commented 2 years ago

Can you edit the README file

Will do!

jirheee commented 2 years ago

Thanks!