Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

changing grunt: localhost livereload: portnumber codio #257

Closed
holyxiaoxin opened this issue Nov 10, 2014 · 6 comments
Closed

changing grunt: localhost livereload: portnumber codio #257

holyxiaoxin opened this issue Nov 10, 2014 · 6 comments

Comments

@holyxiaoxin
Copy link

codio doesn't allow me to use port 35729 for livereload.

Therefore, I have to change this port number. Where can change this port number? Thanks.

@simison
Copy link
Member

simison commented Nov 10, 2014

By changing true from livereload: true to the port number you want at gruntfile.js, like this: https://github.com/gruntjs/grunt-contrib-watch#optionslivereload

@holyxiaoxin
Copy link
Author

Thanks for the quick reply. I have tried to change to:

watch: {
            serverViews: {
                files: watchFiles.serverViews,
                options: {
                    livereload: {
                        port: 9000
                    }
                }
            },
            serverJS: {
                files: watchFiles.serverJS,
                tasks: ['jshint'],
                options: {
                    port: 9000
                }
            },
            clientViews: {
                files: watchFiles.clientViews,
                options: {
                        port: 9000              }
            },
            clientJS: {
                files: watchFiles.clientJS,
                tasks: ['jshint'],
                options: {
                        port: 9000              }
            },
            clientCSS: {
                files: watchFiles.clientCSS,
                tasks: ['csslint'],
                options: {
                        port: 9000              }
            }
        },

But the browser still throws me

WebSocket connection to 'ws://east-hand.codio.io:4000/livereload' failed: Error during WebSocket handshake: Unexpected response code: 502 livereload.js?snipver=1:191

I have tried the tutorial for codio/angular-js but it seems that this is only specific to yeoman/angular. The instructions are as follows:

8. Modify Gruntfile.js
To run properly in Codio, you'll want to open up Gruntfile.js in the root of your App and search for localhost (this area has been highlighted for you) and change this

// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35729
to this

// Change this to '0.0.0.0' to access the server from outside.
hostname: '0.0.0.0',
livereload: 4000    
Codio leaves all Ports between 1024 and 9999 at your disposal, so we need to modify the livereload port.

Also search for <%= yeoman.app %>/{,*/}*.html', (around line 58) to change this:

files: [
      '<%= yeoman.app %>/{,*/}*.html',
      '.tmp/styles/{,*/}*.css',
      '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
    ]
to this

files: [
      '<%= yeoman.app %>/{,*/}*.html',
      '<%= yeoman.app %>/scripts/{,*/}*.js',
      '.tmp/styles/{,*/}*.css',
      '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
    ]
Also (around line 165) remove the following from the wiredep section:

    options: {
       cwd: '<%%= yeoman.app %>'
        },

I guess the default script in meanjs still outputs as 35729. How do I change that to port 9000? Thanks.

@holyxiaoxin
Copy link
Author

I have solve the above problem. It is a simple script change in app/views/layout.server.view.html:

<script type="text/javascript" src="http://localhost:35729/livereload.js"></script>

This community is great. Thanks for the help (:

@simison
Copy link
Member

simison commented Nov 10, 2014

Yup, sorry I forgot to mention it's also hardcoded at the layout. :-) Cheers!

@holyxiaoxin
Copy link
Author

I have been using SailsJS (frontend and backend) for my web+api(for mobile) apps.
Now that I have started with MeanJS and see what it can do right out of the box(authentication and rest APIs, however it's not that 'REST' because of not strictly following the conventions which I have read elsewhere), I would definitely use this if I were to create web-only apps. Can't wait to bootcamp this MEANSTACK. 💃

@simison
Copy link
Member

simison commented Nov 10, 2014

You might want to have a look at #195

pdfowler pushed a commit to pdfowler/mean that referenced this issue Jan 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants