2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/ *  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NodeBB  -  A  better  forum  platform  for  the  modern  web 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									https : //github.com/NodeBB/NodeBB/
 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-29 17:38:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Copyright  ( C )  2013 - 2016   NodeBB  Inc . 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									This  program  is  free  software :  you  can  redistribute  it  and / or  modify 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									it  under  the  terms  of  the  GNU  General  Public  License  as  published  by 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									the  Free  Software  Foundation ,  either  version  3  of  the  License ,  or 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									( at  your  option )  any  later  version . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									This  program  is  distributed  in  the  hope  that  it  will  be  useful , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									but  WITHOUT  ANY  WARRANTY ;  without  even  the  implied  warranty  of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MERCHANTABILITY  or  FITNESS  FOR  A  PARTICULAR  PURPOSE .   See  the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									GNU  General  Public  License  for  more  details . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									You  should  have  received  a  copy  of  the  GNU  General  Public  License 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									along  with  this  program .   If  not ,  see  < http : //www.gnu.org/licenses/>.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								* /  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"use strict" ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/*global require, global, process*/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var  nconf  =  require ( 'nconf' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								nconf . argv ( ) . env ( '__' ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-29 18:22:41 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var  url  =  require ( 'url' ) ,  
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									async  =  require ( 'async' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									winston  =  require ( 'winston' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-03 15:11:42 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									colors  =  require ( 'colors' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									path  =  require ( 'path' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									pkg  =  require ( './package.json' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-02 23:58:01 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									file  =  require ( './src/file' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								global . env  =  process . env . NODE _ENV  ||  'production' ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								winston . remove ( winston . transports . Console ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								winston . add ( winston . transports . Console ,  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									colorize :  true , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									timestamp :  function ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  date  =  new  Date ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  date . getDate ( )  +  '/'  +  ( date . getMonth ( )  +  1 )  +  ' '  +  date . toTimeString ( ) . substr ( 0 , 5 )  +  ' ['  +  global . process . pid  +  ']' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									level :  nconf . get ( 'log-level' )  ||  ( global . env  ===  'production'  ?  'info'  :  'verbose' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-17 21:54:12 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// Alternate configuration file support
  
						 
					
						
							
								
									
										
										
										
											2015-09-17 21:54:12 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var 	configFile  =  path . join ( _ _dirname ,  '/config.json' ) ;  
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  ( nconf . get ( 'config' ) )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									configFile  =  path . resolve ( _ _dirname ,  nconf . get ( 'config' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2015-09-17 21:54:12 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 11:37:18 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								var  configExists  =  file . existsSync ( configFile )  ||  ( nconf . get ( 'url' )  &&  nconf . get ( 'secret' )  &&  nconf . get ( 'database' ) ) ;  
						 
					
						
							
								
									
										
										
										
											2015-09-17 21:54:12 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								loadConfig ( ) ;  
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-24 22:32:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( ! process . send )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// If run using `node app`, log GNU copyright info along with server info
 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-29 17:38:53 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									winston . info ( 'NodeBB v'  +  nconf . get ( 'version' )  +  ' Copyright (C) 2013-'  +  ( new  Date ( ) ) . getFullYear ( )  +  ' NodeBB Inc.' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-24 22:32:40 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									winston . info ( 'This program comes with ABSOLUTELY NO WARRANTY.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									winston . info ( 'This is free software, and you are welcome to redistribute it under certain conditions.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									winston . info ( '' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 19:25:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( nconf . get ( 'setup' )  ||  nconf . get ( 'install' ) )  {  
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									setup ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  else  if  ( ! configExists )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									require ( './install/web' ) . install ( nconf . get ( 'port' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  else  if  ( nconf . get ( 'upgrade' ) )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									upgrade ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  else  if  ( nconf . get ( 'reset' ) )  {  
						 
					
						
							
								
									
										
										
										
											2015-09-17 21:54:12 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									require ( './src/reset' ) . reset ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 19:25:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  else  if  ( nconf . get ( 'activate' ) )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									activate ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-11-03 11:50:14 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  else  if  ( nconf . get ( 'plugins' ) )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									listPlugins ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 19:25:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  else  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									start ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function  loadConfig ( )  {  
						 
					
						
							
								
									
										
										
										
											2015-09-17 21:54:12 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									winston . verbose ( '* using configuration stored in: %s' ,  configFile ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									nconf . file ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										file :  configFile 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									nconf . defaults ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										base _dir :  _ _dirname , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										themes _path :  path . join ( _ _dirname ,  'node_modules' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										views _dir :  path . join ( _ _dirname ,  'public/templates' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										version :  pkg . version 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! nconf . get ( 'isCluster' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										nconf . set ( 'isPrimary' ,  'true' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										nconf . set ( 'isCluster' ,  'false' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Ensure themes_path is a full filepath
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									nconf . set ( 'themes_path' ,  path . resolve ( _ _dirname ,  nconf . get ( 'themes_path' ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									nconf . set ( 'core_templates_path' ,  path . join ( _ _dirname ,  'src/views' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-08-19 14:57:49 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									nconf . set ( 'base_templates_path' ,  path . join ( nconf . get ( 'themes_path' ) ,  'nodebb-theme-persona/templates' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-22 16:24:28 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-22 18:16:09 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( nconf . get ( 'url' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										nconf . set ( 'url_parsed' ,  url . parse ( nconf . get ( 'url' ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-17 21:54:12 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function  start ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  db  =  require ( './src/database' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// nconf defaults, if not set in config
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! nconf . get ( 'upload_path' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										nconf . set ( 'upload_path' ,  '/public/uploads' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-30 13:25:20 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! nconf . get ( 'sessionKey' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										nconf . set ( 'sessionKey' ,  'express.sid' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Parse out the relative_url and other goodies from the configured URL
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  urlObject  =  url . parse ( nconf . get ( 'url' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  relativePath  =  urlObject . pathname  !==  '/'  ?  urlObject . pathname  :  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									nconf . set ( 'base_url' ,  urlObject . protocol  +  '//'  +  urlObject . host ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-06 14:35:00 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									nconf . set ( 'secure' ,  urlObject . protocol  ===  'https:' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									nconf . set ( 'use_port' ,  ! ! urlObject . port ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									nconf . set ( 'relative_path' ,  relativePath ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-23 15:10:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									nconf . set ( 'port' ,  urlObject . port  ||  nconf . get ( 'port' )  ||  nconf . get ( 'PORT' )  ||  ( nconf . get ( 'PORT_ENV_VAR' )  ?  nconf . get ( nconf . get ( 'PORT_ENV_VAR' ) )  :  false )  ||  4567 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-08 13:21:05 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									nconf . set ( 'upload_url' ,  nconf . get ( 'upload_path' ) . replace ( /^\/public/ ,  '' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( nconf . get ( 'isPrimary' )  ===  'true' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										winston . info ( 'Time: %s' ,  ( new  Date ( ) ) . toString ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										winston . info ( 'Initializing NodeBB v%s' ,  nconf . get ( 'version' ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-17 21:54:12 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  host  =  nconf . get ( nconf . get ( 'database' )  +  ':host' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											storeLocation  =  host  ?  'at '  +  host  +  ( host . indexOf ( '/' )  ===  - 1  ?  ':'  +  nconf . get ( nconf . get ( 'database' )  +  ':port' )  :  '' )  :  '' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										winston . verbose ( '* using %s store %s' ,  nconf . get ( 'database' ) ,  storeLocation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										winston . verbose ( '* using themes stored in: %s' ,  nconf . get ( 'themes_path' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									process . on ( 'SIGTERM' ,  shutdown ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									process . on ( 'SIGINT' ,  shutdown ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									process . on ( 'SIGHUP' ,  restart ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									process . on ( 'message' ,  function ( message )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( typeof  message  !==  'object' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  meta  =  require ( './src/meta' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  emitter  =  require ( './src/emitter' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										switch  ( message . action )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											case  'reload' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												meta . reload ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											case  'js-propagate' : 
							 
						 
					
						
							
								
									
										
										
										
											2016-03-31 13:03:36 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												meta . js . target  =  message . data ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												emitter . emit ( 'meta:js.compiled' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												winston . verbose ( '[cluster] Client-side javascript and mapping propagated to worker %s' ,  process . pid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											case  'css-propagate' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												meta . css . cache  =  message . cache ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												meta . css . acpCache  =  message . acpCache ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												emitter . emit ( 'meta:css.compiled' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												winston . verbose ( '[cluster] Stylesheets propagated to worker %s' ,  process . pid ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											case  'templates:compiled' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												emitter . emit ( 'templates:compiled' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									process . on ( 'uncaughtException' ,  function ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										winston . error ( err . stack ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										console . log ( err . stack ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										require ( './src/meta' ) . js . killMinifier ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										shutdown ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									async . waterfall ( [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										async . apply ( db . init ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										async . apply ( db . checkCompatibility ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										function ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											require ( './src/meta' ) . configs . init ( next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										function ( next )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-02 17:00:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( nconf . get ( 'dep-check' )  ===  undefined  ||  nconf . get ( 'dep-check' )  !==  false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												require ( './src/meta' ) . dependencies . check ( next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-07-05 11:28:27 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												winston . warn ( '[init] Dependency checking skipped!' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-06-02 17:00:24 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												setImmediate ( next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										function ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											require ( './src/upgrade' ) . check ( next ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										function ( next )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											var  webserver  =  require ( './src/webserver' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											require ( './src/socket.io' ) . init ( webserver . server ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( nconf . get ( 'isPrimary' )  ===  'true'  &&  ! nconf . get ( 'jobsDisabled' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												require ( './src/notifications' ) . init ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												require ( './src/user' ) . startJobs ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											webserver . listen ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									] ,  function ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											switch ( err . message )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												case  'schema-out-of-date' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													winston . warn ( 'Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													winston . warn ( '    ./nodebb upgrade' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												case  'dependencies-out-of-date' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													winston . warn ( 'One or more of NodeBB\'s dependent packages are out-of-date. Please run the following command to update them:' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													winston . warn ( '    ./nodebb upgrade' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
									
										
										
										
											2016-04-07 10:47:13 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												case  'dependencies-missing' : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													winston . warn ( 'One or more of NodeBB\'s dependent packages are missing. Please run the following command to update them:' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													winston . warn ( '    ./nodebb upgrade' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													if  ( err . stacktrace  !==  false )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														winston . error ( err . stack ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														winston . error ( err . message ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Either way, bad stuff happened. Abort start.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											process . exit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function  setup ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									winston . info ( 'NodeBB Setup Triggered via Command Line' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  install  =  require ( './src/install' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									process . stdout . write ( '\nWelcome to NodeBB!\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									process . stdout . write ( '\nThis looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									process . stdout . write ( 'Press enter to accept the default setting (shown in brackets).\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									install . setup ( function  ( err ,  data )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  separator  =  '     ' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( process . stdout . columns  >  10 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											for ( var  x = 0 , cols = process . stdout . columns - 10 ; x < cols ; x ++ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												separator  +=  '=' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										process . stdout . write ( '\n'  +  separator  +  '\n\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											winston . error ( 'There was a problem completing NodeBB setup: ' ,  err . message ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( data . hasOwnProperty ( 'password' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												process . stdout . write ( 'An administrative user was automatically created for you:\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												process . stdout . write ( '    Username: '  +  data . username  +  '\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												process . stdout . write ( '    Password: '  +  data . password  +  '\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												process . stdout . write ( '\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											process . stdout . write ( 'NodeBB Setup Completed. Run \'./nodebb start\' to manually start your NodeBB server.\n' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// If I am a child process, notify the parent of the returned data before exiting (useful for notifying
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// hosts of auto-generated username/password during headless setups)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( process . send )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												process . send ( data ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										process . exit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function  upgrade ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									require ( './src/database' ) . init ( function ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											winston . error ( err . stack ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											process . exit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										require ( './src/meta' ) . configs . init ( function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											require ( './src/upgrade' ) . upgrade ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 19:25:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function  activate ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									require ( './src/database' ) . init ( function ( err )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-16 19:46:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											winston . error ( err . stack ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											process . exit ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-23 12:42:21 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  plugin  =  nconf . get ( '_' ) [ 1 ]  ?  nconf . get ( '_' ) [ 1 ]  :  nconf . get ( 'activate' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 19:25:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											db  =  require ( './src/database' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-17 15:04:32 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										winston . info ( 'Activating plugin %s' ,  plugin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-09-17 17:17:46 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										db . sortedSetAdd ( 'plugins:active' ,  0 ,  plugin ,  start ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2015-09-16 19:25:05 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-03 11:50:14 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function  listPlugins ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									require ( './src/database' ) . init ( function ( err )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-16 19:46:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											winston . error ( err . stack ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											process . exit ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-03 11:50:14 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										var  db  =  require ( './src/database' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										db . getSortedSetRange ( 'plugins:active' ,  0 ,  - 1 ,  function ( err ,  plugins )  { 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-16 19:46:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												winston . error ( err . stack ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												process . exit ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-11-03 11:50:14 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											winston . info ( 'Active plugins: \n\t - '  +  plugins . join ( '\n\t - ' ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											process . exit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-07-21 11:23:16 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function  shutdown ( code )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									winston . info ( '[app] Shutdown (SIGTERM/SIGINT) Initialised.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									require ( './src/database' ) . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									winston . info ( '[app] Database connection closed.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									require ( './src/webserver' ) . server . close ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									winston . info ( '[app] Web server closed to connections.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									winston . info ( '[app] Shutdown complete.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									process . exit ( code  ||  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function  restart ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( process . send )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										winston . info ( '[app] Restarting...' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										process . send ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											action :  'restart' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										winston . error ( '[app] Could not restart server. Shutting down.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										shutdown ( 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}