MonthFebruary 2016

Nodes Forever Package Doesn’t Mean Forever!

I run most of my node apps on a droplet with DigitalOcean. Recently there was an issue and the droplet had to be restarted by them, but my app didn’t restart. This was a big issue for me and my client. I use Forever to run the app, but this only works if the app crashes and not when the server is rebooted.

The solution to this is to use an Upstart script. The one below is an example of one I use, as you can see its pretty small. The scripts can get rather complex and it all depends on your needs.

The scripts need to live in /etc/init/ directory and with a .conf file extension.

The script can be started by running sudo service appname start. 

Access and Update Model Outside Angular

In a recent project I had a form within an Iframe that needed to talk to the parent frame via postMessage. The parent frame was an angular application and I had to show and hide some content. I was able to access the scope outside angular and update via the angular.element() method (This is using version 1.4.2).


Using Pathmodify a Browserify plugin with Gulp

To better understand what we are going to solve in this post take a look at what Pathmodify does.


Notice lines 8-11 which is where the pathmodify plugin is used. On lines 9-10 is where we will alias a directory. We will take line 10 as an example from here on. The method .dir in pathmodify.mod.dir() takes two arguments. The first is the name of the alias in this case it’s “ng_services”, and this can be anything you want. The second argument is the absolute system path where your in this case angular services reside.


Now, in our app.js file we can use these new alias within our require() methods.  Take a look at all the require methods and notice how the alias are used.  So, now instated of using something along the lines of ../../../../../ you can just use the alias.

© 2017 Aldo Lugo

Theme by Anders NorenUp ↑