A
A
AndeDark2021-06-15 22:50:01
Software Deployment
AndeDark, 2021-06-15 22:50:01

Application deployment nuances?

Hello! There was a need to deploy my service (I use the google cloud platform). And since I had never encountered this before, a couple of questions arose.

  1. How can I connect to SQL Server?
    Working locally, I used the usual connection pool, in which I specified local addresses for connecting to the postgres database, will it work the same way if I specify the address of my SQL server instead of local addresses? Or is it done in some other way?
    const {Pool} = require('pg');
    
    const pool = new Pool({
        user: "macbookpro",
        password: "root",
        host: "localhost",
        port: 5432,
        database: "umuse"
    });
    
    module.exports = pool;


  2. What address to specify for sockets?
    I work with the socket.io library and to connect to sockets on the client, I specify the server address, if both the client and the server will spin on the same machine with an address such as 392.118.23.11, which I will need to write instead of localhost... ?
    import io from 'socket.io-client';
    
    const socket = io('http://localhost:5000');
    
    export default socket;


Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Makhov, 2021-06-15
@AndeDark

1. Make sure that the config is loaded from .envthe environment variables using the dotenv module - this is the most classic practice. The database will need to be deployed either on the same machine where you are deploying (you can do it with docker-compose) or on a neighboring machine that you can access from the first one. Make sure that the data between the database and the application does not race over the Internet, as this a) reduces security to zero if there is no ssl and b) greatly reduces performance.
2. It's best to either not specify anything here, or specify 0.0.0.0, then all interfaces will listen and you won't have to bother with ip addresses. Or there is a more advanced option when you leave localhost, but nginx with proxy_pass is placed in front of the node application. In the second case, it will also be possible to attach an ssl certificate using letsencrypt

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question