Question T448
Visible to All Users

Cannot start NodeJS backend

created 7 years ago

I'm trying to get a copy of the NodeJS backend running on my machine. I've installed Docker for Windows and cloned the repository to D:\Repositories\surveyjs-nodejs.

Following the README.md, I open PowerShell, move to D:\Repositories\surveyjs-nodejs\docker\postgresql-db, and run docker build -t postgresql-db . That returns "succesfully built", with a security warning that since I'm running on Windows, "all files and directories added to build context will have '-rwxr-xr-x' permissions", which seems fine for test purposes.

As instructed, I ran docker run --name dbsrv -p 5432:5432 -d postgresql-db earlier. I seem to remember it working; now when I run it, I get "The container name "/dbsrv" is already in use".

I'm not super familiar with docker or docker-compose, but the only remaining thing to do seems to be to run docker-compose up from the docker folder, so I do that, and it seems to succeed. Here's the output I get:

Code
Starting docker_dbsrv_1 ... done Attaching to docker_dbsrv_1 dbsrv_1 | 2018-02-20 17:44:01 UTC [5-1] LOG: database system was shut down at 2018-02-20 17:00:31 UTC dbsrv_1 | 2018-02-20 17:44:01 UTC [5-2] LOG: MultiXact member wraparound protections are now enabled dbsrv_1 | 2018-02-20 17:44:01 UTC [1-1] LOG: database system is ready to accept connections dbsrv_1 | 2018-02-20 17:44:01 UTC [9-1] LOG: autovacuum launcher started

This seems promising. The next thing the documentation says is: "At this point demo surveyjs-nodejs service will be available at the http://localhost:3000 address. If everything is ok, you should see project home page with list of available surveys and links to Survey and Editor pages." So I open http://localhost:3000 in Firefox, and I get "Unable to connect. Firefox can't establish a connection to the server at localhost:3000."

It seems like the database server is running, but perhaps not the web server? I look around in the repo and find an index.js in the root folder. I run that with node index.js and get the output "Listening on port 3000!" Great! But I open http://localhost:3000 in Firefox again and it still says "Unable to connect".

This is very strange. All of the servers seem to be running flawlessly as far as I can tell, except that I can't connect to them. Can you suggest a course of action?

Comments (3)

    Hello,

    Yes, I forgot to write that one should install node modules and start the server via npm start command.
    I've updated the getting started guide in the repo, please check it - https://github.com/surveyjs/surveyjs-nodejs
    InMemoryDataAdapter has been added and it become easier to start the example - it doesn't requires postgresql db - it stores surveys and data in the session by default.
    Don't forget to pull recent changes.
    Hope this helps.

    Thanks, Serge
    SurveyJS Team

      That got it working, thank you!

      Possible typo: "Clone this repository in the surveyjs-nodejs folder (and make in current directory via cd surveyjs-nodejs)". Should "make in current directory" be "make it current directory"? "Make in current directory" sounds like you're asking me to use a make tool.

      Also, when you say "Note: if you are familliar with docker and docker-compose, just run docker-compose up from the docker folder," is that intended to replace docker build -t postgresql-db . or docker run --name dbsrv -p 5432:5432 -d postgresql-db or both?

        Hello,

        Thank you for suggestions, I've changed readme file.

        Thanks, Serge
        SurveyJS Team