Sailjs + Angularjs + Yeoman + Grunt can't start angular server - angularjs

I have an Sailjs (frontend+backend) app that's up and running. However, I would like to separate my frontend(angularjs) and backend(sailsjs). Therefore, I'm trying to follow a tutorial on it: link.
However, it was all smooth until I tried to start the angular server in port 9000 using grunt serve.
~/workspace/web/frontend$ grunt serve
Running "serve" task
Running "clean:server" (clean) task
Cleaning .tmp...OK
Running "wiredep:app" (wiredep) task
Running "wiredep:sass" (wiredep) task
Running "concurrent:server" (concurrent) task
Running "compass:server" (compass) task
directory .tmp/styles
write .tmp/styles/main.css (4.936s)
Done, without errors.
Execution Time (2014-11-10 05:36:51 UTC)
compass:server 6s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100%
Total 6s
Running "autoprefixer:dist" (autoprefixer) task
File .tmp/styles/main.css created.
Running "connect:livereload" (connect) task
Started connect web server on http://localhost:9000
Running "watch" task
Waiting...
It looks like the server has been started and when I navigate to ~nitrous.io:9000/ it doesn't show anything. However, my sails page is up at ~nitrious.io:1337/ I believe it is suppose to show a yeoman page? I am not familiar with angular + yo + grunt. Is there something that I did wrong?

I have realised that you need to config grunt settings and change the hostname to access it from nitrious io.
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
change this -->hostname: '0.0.0.0',
livereload: 35729
},
However, I have met with another problem.
GET http://nodejs-160326.apse1.nitrousbox.com:35729/livereload.js?snipver=1 net::ERR_CONNECTION_TIMED_OUT
Somehow the script can't seem to load.

Related

Zeppelin Disconnect status error

I'm using Zeppelin 0.70. I can build zeppelin from git source. when i trying to start zeppelin on that port 8000 by using below command, it works good.
./zeppelin-daemon start
But It won't work after grunt serve command on the port 9000, but it started good and it shows web socket disconnected error.
[root#sandbox zeppelin-web]# ./grunt serve
Running "serve" task
Running "clean:server" (clean) task
Cleaning .tmp...OK
Running "wiredep:app" (wiredep) task
Running "wiredep:test" (wiredep) task
Running "concurrent:server" (concurrent) task
Running "copy:styles" (copy) task
Copied 16 files
Done, without errors.
Execution Time (2017-02-24 05:51:45 UTC)
loading tasks 277ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 91%
copy:styles 28ms ▇▇▇▇▇ 9%
Total 305ms
Running "postcss:dist" (postcss) task
>> 16 processed stylesheets created.
Running "connect:livereload" (connect) task
Started connect web server on http://0.0.0.0:9000
Running "watch" task
Waiting...
I got log in console;
XMLHttpRequest cannot load http://localhost:8080/api/security/ticket. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9000' is therefore not allowed access. The response had HTTP status code 404.
Where do i change 8080 to 8000.
Please tell me how do i resolve this issue.
I think grunt was substituted with npm in 0.7 release, so could you try npm run dev command?
Update: There's ongoing issue under ZEPPELIN-2154 related to it. In order to fix it in your case you could remove 3 lines in here of if statement and substitute it with port = 8000; in your source code. it could be temporary fix until patch is filed to make it configurable.

CircleCI Protractor wait for server to start

I am trying to use Protractor on my project through CircleCI for E2E testing.
Starting my server takes a long time (around 2 minutes), and I am getting the following error on my tests (which shows locally when the server has not started):
Failed: Angular could not be found on the page http://test.blah.dev:3000/auth/login : retries looking for angular exceeded
Here is my circle.yml:
machine:
node:
version: 5.11.0
dependencies:
post:
- npm run serve-dist: # starts the server
background: true
- sleep 150 # wait for the server to start
test:
pre:
- npm install -g protractor
- webdriver-manager update
- webdriver-manager start:
background: true
I then run npm test, which includes the command protractor conf.js
I want to figure out a better way to wait for the server to start on CircleCI. Can someone tell me what I am doing wrong?
So it turns out that there are some other steps in the setup of my project that I was missing... in particular, I needed to add names to the /etc/hosts file, and some environmental variable to connect to my mongo instance, like so:
machine:
hosts:
test.blah.dev: 127.0.0.1
environment:
MONGOLAB_URL: mongodb://localhost/testdatabase
So it wasn't an issue with waiting for the server to start (using background: true and sleep should take care of the waiting).

angular fullstack generator grunt serve ERR_CONNECTION_REFUSED

I'm building a project on a yeoman angular-fullstack generator. It's been a quite a while and the landing page was correctly loading after running grunt serve task.
I really don't know what I've done but now when I run grunt serve I see ERR_CONNECTION_REFUSED message in chrome first and then the landing page loads normally(about 5 seconds after ERR_CONNECTION_REFUSED message)
This makes my e2e tests crash.
found some issues on github about grunt-concurrent downgrading and disabling livereload but nothing helps..
This is the log. As you see express server has to start listening before open server and watch tasks( newly created fullstack-generator does that so it works correctly)
Running "serve" task
Running "clean:server" (clean) task
>> 1 path cleaned.
Running "env:all" (env) task
Running "concurrent:pre" (concurrent) task
Running "ngconstant:app" (ngconstant) task
Creating module serviceboxApp.constants at client/app/app.constant.js...OK
Done, without errors.
Execution Time (2016-02-26 00:40:08 UTC)
loading tasks 302ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 85%
loading grunt-ng-constant 34ms ▇▇▇▇ 10%
ngconstant:app 19ms ▇▇ 5%
Total 356ms
Running "concurrent:server" (concurrent) task
Running "newer:babel:client" (newer) task
Running "babel:client" (babel) task
Running "newer-postrun:babel:client:1:/Users/apple/Desktop/dev/servicebox/node_modules/grunt-newer/.cache" (newer-postrun) task
Done, without errors.
Execution Time (2016-02-26 00:40:09 UTC)
loading tasks 312ms ▇▇▇▇▇▇▇ 15%
newer:babel:client 36ms ▇ 2%
loading grunt-babel 415ms ▇▇▇▇▇▇▇▇▇ 20%
babel:client 1.2s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 61%
Total 2s
Running "injector:scripts" (injector) task
Missing option `template`, using `dest` as template instead
Injecting js files (33 files)
Running "injector:css" (injector) task
Missing option `template`, using `dest` as template instead
Injecting css files (9 files)
Running "wiredep:client" (wiredep) task
Running "postcss:dist" (postcss) task
Running "express:dev" (express) task
Starting background Express server
Debugger listening on port 5858
[TypeError: Cannot read property 'Kerberos' of undefined]
Running "wait" task
>> Waiting for server reload...
Done waiting!
Running "open:server" (open) task
Running "watch" task
Waiting...
Express server listening on 9000, in development mode
finished populating users
finished populating quotes
finished populating poviders
You have TypeError that is preventing your code from running properly. [TypeError: Cannot read property 'Kerberos' of undefined]
You don't know JS explains that a TypeError "implies that Scope resolution was successful, but that there was an illegal/impossible action attempted against the result."
So you need to go back to where you are calling Kerberos and resolve the TypeError

Start Selenium server automatically for e2e testing

I followed this SO post
to set up my Gruntfile. If I manually downloaded Selenium standalone and specified its location in the file, my test runs successfully. Since I would like to automate this process, I tried the following configuration:
protractor_webdriver: {
start: {
options: {
path: 'node_modules/grunt-protractor-runner/node_modules/protractor/bin/',
command: 'webdriver-manager start'
}
}
};
grunt.loadNpmTasks('grunt-protractor-webdriver');
grunt.registerTask('test', ['protractor_webdriver:start','protractor:run'])
Is there a way to avoid downloading manually? I tried the above but when I ran it, I got the warning:
Running "protractor_webdriver:start" (protractor_webdriver) task
Verifying property protractor_webdriver.start exists in config...OK
File: [no files]
Options: path="node_modules/grunt-protractor-runner/node_modules/protractor/bin/", command="webdriver-manager start", keepAlive=false
Starting Selenium server
>> Selenium Standalone is not present.
Install with webdriver-manager update --standalone
So I still need to download the selenium standalone server manually?
Or maybe I missed some configuration here?
Protractor is a wrapper around WebDriverJS.
It's a nodejs program that interacts with Selenium Server and specific Browser drivers (e.g. ChromeDriver, IEDriver).
So, without using selenium server (at least for IE), you cannot run tests written with protractor. Test scripts send commands to the Selenium Server, which in turn then communicates with the browser driver. See this for a description of the architecture.
In a nutshell, without having started a Selenium server instance beforehand, nothing will happen.
You can run Protractor without Selenium by specifying
directConnect: true
in your respective Protractor configuration file (e.g. protractor.conf.js).

Access error running chrome from grunt test

I am trying to run karma tests on my angular project. I used yeoman to create the angular project. However when I am trying to run tests, I am getting following errors
grunt test
Running "clean:server" (clean) task
Running "concurrent:test" (concurrent) task
Running "coffee:dist" (coffee) task
Running "coffee:test" (coffee) task
Done, without errors.
Running "connect:test" (connect) task
Started connect web server on localhost:9000.
Running "karma:unit" (karma) task
INFO [karma]: Karma server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [watcher]: Pattern "/home/arpit/proj/proj1/views/test/mock/**/*.js" does not
match any file.
ERROR [launcher]: Cannot start Chrome
Error: spawn EACCES
INFO [launcher]: Trying to start Chrome again.
ERROR [launcher]: Cannot start Chrome
Error: spawn EACCES
INFO [launcher]: Trying to start Chrome again.
ERROR [launcher]: Cannot start Chrome
Error: spawn EACCES
Warning: Task "karma:unit" failed. Use --force to continue.
Aborted due to warnings.
I can run chrome from bash using same account successfully with which I am trying to run grunt test
Also, sudo grunt test is running fine.
On the Mac, it's important to set CHROME_CANARY_BIN
to binary file, not just to app package.
In my case, problem emerged from installing Chrome via brew cask, so I had to set
export CHROME_CANARY_BIN="/opt/homebrew-cask/Caskroom/google-chrome-canary/latest/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary"
In most cases you have to set a environment variable "CHROME_BIN" to point at your chrome.exe
Windows:
set CHROME_BIN=C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Mac 10.7.5
I was able to set it using the following
export CHROME_BIN=/Applications/Chrome.app/Contents/MacOS/Google\ Chrome
You get to the exec file by right clicking on the .app and selecting the Show Package Contents option. Follow this down to the executable and click it. It brought up the path in the terminal.

Resources