npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dpd-openshift-start-script

v2.3.3

Published

Node module that wrap around configuring and starting deployd instance on localhost and openshift in a lazy way.

Downloads

12

Readme

dpd-openshift-start-script

Node module that wrap around configuring and starting deployd instance on localhost and openshift in a lazy way.

Author: Patryk "ipepe" Ptasiński

Mail: [email protected]

credits

Based on code: schettino72 http://blog.schettino72.net/posts/mongodb-setup-deployd-heroku.html

license

Apache License v2

changelog

  • v2.3.0 - added callback so You know when Deployd is started. Useful for using dpd-internalClient, added changelog to readme
  • v2.2.0 - refactored exporting of object, adjusted readme
  • v2.1.0 - added dpd-internalClient into returned object
  • v2.0.0 - first version of creating real module with export
  • v1.1.0 - added optional heroku env strings to uncomment
  • v1.0.0 - project started

pre-usage

Install mongodb:

http://docs.mongodb.org/manual/installation/

You should have configured database with login/pass/database name: deployd/deployd/deployd. To configure run in bash:

mongo shell

create user deployd with password deployd in database name: deployd

use admin
db.addUser( { user: "deployd", pwd: "deployd", roles: [ "userAdminAnyDatabase" ] } )
use deployd
db.addUser( { user: "deployd", pwd: "deployd", roles: [ "readWrite", "dbAdmin" ] } )

usage for v2.x

MongoDB start (or have you should have it running as a service)

sudo mongod

Create an index.js file in Your project:

// ==================== Load/start dependencies
var deployd_setup = require('dpd-openshift-start-script');
var deployd_instance = deployd_setup(deploydStartedCallback);
var colors = deployd_instance.colors;

function deploydStartedCallback(){
	//some code that requires deployd, maybe some operations on dpd-internalClient?
	console.log('You started deployd server by: ' + colors.magenta('dpd-openshift-start-script'));
	deployd_instance.dpd_ic.logger.post( {time: Date.now(), body: "Deployd server started"}, console.log)
}

Objects returned:

deployd_instance.deployd = require('deployd');
deployd_instance.internalClient = require('deployd/lib/internal-client');
deployd_instance.url = require('url');
deployd_instance.colors = require('colors');
deployd_instance.server_env = process.env.NODE_ENV || 'development';
deployd_instance.server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
deployd_instance.server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
deployd_instance.db_ip_address = process.env.OPENSHIFT_MONGODB_DB_HOST || deployd_instance.server_ip_address;
deployd_instance.db_url_address = process.env.OPENSHIFT_MONGODB_DB_URL || 'mongodb://deployd:deployd@'+deployd_instance.db_ip_address+':27017/deployd';
deployd_instance.db_parsed_url = deployd_instance.url.parse(deployd_instance.db_url_address);

deployd_instance.server = deployd_instance.deployd({
	port: deployd_instance.server_port,
	env: deployd_instance.server_env,
	db: {
		host: deployd_instance.db_parsed_url.hostname,
		port: parseInt(deployd_instance.db_parsed_url.port),
		name: deployd_instance.db_parsed_url.pathname.slice(1),
		credentials: {
			username: deployd_instance.db_parsed_url.auth.split(':')[0],
			password: deployd_instance.db_parsed_url.auth.split(':')[1]
		}
	}
});
//internal client is not defined until deployd server starts, You shouldn't use it before my script runs Your callback.
deployd_instance.dpd_ic = deployd_instance.internalClient.build(process.server);

usage for v1.x

You should have mongoDB running in background as a service or in separate terminal window with

sudo mongod

Example code in unix terminal:

mkdir testproject
cd testproject
touch server.js
npm init
npm i deployd --save
npm i dpd-openshift-start-script --save
cp node_modules/dpd-openshift-start-script/server.js  ./
mkdir resources
node server.js

code inside v2.3

//Author: Patryk "ipepe" Ptasiński [email protected], credit to: schettino72
module.exports = function (after_start_callback) {
	var deployd_instance = {};
	deployd_instance.deployd = require('deployd');
	deployd_instance.internalClient = require('deployd/lib/internal-client');
	deployd_instance.url = require('url');
	deployd_instance.colors = require('colors');
	// ==================== Server Envs
	deployd_instance.server_env = process.env.NODE_ENV || 'development';
	deployd_instance.server_port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
	deployd_instance.server_ip_address = process.env.OPENSHIFT_NODEJS_IP || '127.0.0.1';
	// ==================== Database Envs
	deployd_instance.db_ip_address = process.env.OPENSHIFT_MONGODB_DB_HOST || deployd_instance.server_ip_address;
	// OPENSHIFT DB ADDRESS
	deployd_instance.db_url_address = process.env.OPENSHIFT_MONGODB_DB_URL || 'mongodb://deployd:deployd@'+deployd_instance.db_ip_address+':27017/deployd';
	// HEROKU DB ADDRESS
	// var db_url_address = process.env.MONGOHQ_URL || 'mongodb://deployd:deployd@'+deployd_instance.db_ip_address+':27017/deployd';
	deployd_instance.db_parsed_url = deployd_instance.url.parse(deployd_instance.db_url_address);
	// ==================== Output current app config
	console.log( deployd_instance.colors.yellow(deployd_instance.server_env) );
	console.log( deployd_instance.colors.yellow(deployd_instance.server_ip_address + ':' + deployd_instance.server_port) );
	console.log( deployd_instance.colors.yellow(deployd_instance.db_url_address) );
	// ==================== Configure DeployD instance
	deployd_instance.server = deployd_instance.deployd({
		port: deployd_instance.server_port,
		env: deployd_instance.server_env,
		db: {
			host: deployd_instance.db_parsed_url.hostname,
			port: parseInt(deployd_instance.db_parsed_url.port),
			name: deployd_instance.db_parsed_url.pathname.slice(1),
			credentials: {
				username: deployd_instance.db_parsed_url.auth.split(':')[0],
				password: deployd_instance.db_parsed_url.auth.split(':')[1]
			}
		}
	});
	// ==================== Listen
	deployd_instance.server.listen(deployd_instance.server_port, deployd_instance.server_ip_address);
	deployd_instance.server.on('listening', function() {
		deployd_instance.dpd_ic = deployd_instance.internalClient.build(process.server);
		console.log( deployd_instance.colors.green('Server is listening') );
		if ( typeof after_start_callback !== undefined ) after_start_callback();
	});
	// ==================== Catch Errors
	deployd_instance.server.on('error', function(err) {
		console.error( deployd_instance.colors.red(err) );
		// Give the server a chance to return an error
		process.nextTick(function() {
			process.exit();
		});
	});
	return deployd_instance;
};