LINCnil/pia-back

Struggling to make the app run on Google App Engine

Closed this issue · 12 comments

Hello,
Thank you for the good work on this project !
We ran the app locally, connecting it to a db on GCP via proxy using something like :

development:
  adapter:  postgresql
  host: 127.0.0.1
  encoding: unicode
  database: pia-db
  pool:     5
  timeout: 5000
  username: postgres
  password: test

Now we deployed to app engine with a config like :

production:
  adapter:  postgresql
  host: /cloudsql/[INSTANCE_NAME]
  database: pia-db
  timeout: 5000
  pool:     5
  username: postgres
  password: test

But the moment we try to connect our front with the back via Settings using the deployed backend service url, it says connection is impossible. The logs on app engine don't say much, juste server error 500 on / GET /pias, with this only error :

image

We're new to rails, and we would appreciate any help

Thank you

Hello,

As said my friend, we are new to rails.

Thank you very much for your help,

Regards,

Amina

Hello,
I think the URI is wrong, instead of host: /cloudsql/[INSTANCE_NAME] you should have smtg like host: postgres://xxxxxxxx. I'm not familiar with GCP but I think you can find the host in the console.
We can help you if needed with screen sharing or more.
Best

Hello @brunto ,
Thank you for the quick response
The URL was indeed wrong, I just updated with a public IP of the pg instance

we now have an error but it looks like it's related to connectivity :

PG::ConnectionBad (could not connect to server: Connection timed out Is the server running on host "xx.xxx.xxx.xxx" and accepting TCP/IP connections on port 5432?
The instance is reachable from local via proxy, we'll look around if there is something missing, or maybe try with vpc as there are more documentations providing a how-to.
We'll make sure to put a runbook to deploy on GCP for future devs once everything is up and running.

Best regards

I think you must open port 5432 to be accessible from your server.

Hello, we have tried with private IP and VPC, but the same error. I don't know what I'm missing exactly to make it run, as it runs locally with 127.0.0.1 and cloud proxy. We still have an error:
PG::ConnectionBad (could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
):

Sorry to hear that. Maybe you can try with Google cloud support?

Hello Brunto,

We have finally succeeded into linking the backend to cloud sql by using :

1- Setting cloud_sql_instances under beta_settings in app.yaml.
2- in database.yml the following config for prod :

 production:

    adapter:  postgresql
    host: /cloudsql[INSTANCE_NAME]
    database: database_name
    timeout: 5000
    pool:     5
    username: postgres
    password: test

We are facing a new issue with file upload using fog-gcloud to upload on google-cloud-storage.
The file is uploaded successfully, but the findAllByPia()
returns the following error :
main.b770875eb1c4dfac7bf1.js:35642 Request failed TypeError: Failed to execute 'json' on 'Response': body stream already read

On first look, the attachment is indeed saved on Cloud storage under /data, and an entry is also created in the table attachments. The error is raised on the method create(attachment) on the catch block.

Any ideas what it might be linked to ?

Thank you

Hello Brunto,

We have finally succeeded into linking the backend to cloud sql by using :

1- Setting cloud_sql_instances under beta_settings in app.yaml.
2- in database.yml the following config for prod :

 production:

    adapter:  postgresql
    host: /cloudsql[INSTANCE_NAME]
    database: database_name
    timeout: 5000
    pool:     5
    username: postgres
    password: test

We are facing a new issue with file upload using fog-gcloud to upload on google-cloud-storage.
The file is uploaded successfully, but the findAllByPia()
returns the following error :
main.b770875eb1c4dfac7bf1.js:35642 Request failed TypeError: Failed to execute 'json' on 'Response': body stream already read

On first look, the attachment is indeed saved on Cloud storage under /data, and an entry is also created in the table attachments. The error is raised on the method create(attachment) on the catch block.

Any ideas what it might be linked to ?

Thank you

Edit :
This is the resolve(result) of findAllByPia(pia_id) that I get once I load the pia, yet the previously uploaded file does not appear under attachments :

image

Hello @saadlalam
Happy to see that everything works for the database.
About the errors with the attachments, could you provide more information/log/... ?

Hello @brunto ,

Here are more info regarding the issue :
config/initializers/carrierwave.rb:

On my gem file :
gem 'carrierwave-google-storage'

image

config/environments.production.rb:
config.active_storage.service is commented.

config/uploaders/file_uploader.rb:
image

Server error:

image

client error (no obfuscation) :

image


Currently, we are using the default storage option (on disk, and without the setup above) but we have an issue because whenever we upload an attachment on a PIA, it appears on all of the other PIAs.

p.s : I also tried google storage as mentioned in storage.yml but I kept getting :
image and I let go.

Thank you

@saadlalam we'll try to find some times to test GCS and we'll update the Wiki.

Hi there,

Sorry for the late answer, I'm getting back on this topic.
@saadlalam, @AZugari, could you fix your different issues? Could you resolve them?

Regards,