Node-launchd.plist

An easier way to create launchd plists

View project onGitHub

Plist()

Constructor

Plist.addBoolean(k:String, v:Boolean)

Adds a boolean to the plist object for the given k

Example

 plist.addBoolean('Disabled', true)

Plist.addString(k:String, v:String, mand:Array)

Adds a string to the plist object for the given k

If mand is not an array, then no restrictions are placed

Example

 plist.addString('Label', 'com.curapps.test')

Plist.addArray(k:String, v:Array|String|Number|Object)

Adds an array to the plist object for the given k

NOTE: Any value that is not an array will be wrapped in an array

Example

 plist.addArray('ProgramArguments', ['/usr/local/bin/node', 'test.js'])

Plist.addNumber(k:String, v:Number)

Adds a number to the plist object for the given k

Example

 plist.addNumber('TimeOut', 30)

Plist.addObject(k:String, v:Object)

Adds an object to the plist object for the given k

Example

 var obj = { DEBUG: 'Plist*' };
 plist.addObject('EnvironmentVariables', obj)

Plist.setDisabled(disabled:Boolean)

Sets the Disabled bool

Example

 plist.setDisabled(true)

Plist.setEnableGlobbing(globbing:Boolean)

Sets the EnableGlobbing bool

Example

 plist.setEnableGlobbing(false)

Plist.setEnableTransactions(transactions:Boolean)

Sets the EnableTransactions bool

Example

 plist.setEnableTransactions(true)

Plist.setOnDemand(ondemand:Boolean)

Sets the OnDemand bool

Example

 plist.setOnDemand(false)

Plist.setRunAtLoad(runatload:Boolean)

Sets the RunAtLoad bool

Example

 plist.setRunAtLoad(true)

Plist.setInitGroups(groups:Boolean)

Sets the InitGroups bool

Example

 plist.setInitGroups(false)

Plist.setInetdCompatibilityWait(wait:Boolean)

Sets the inetdCompatibility.Wait bool

Example

 plist.setInetdCompatibilityWait(false)

Plist.setStartOnMount(s:Boolean)

Sets the StartOnMount bool

Example

 plist.setStartOnMount(true)

Plist.setDebug(d:Boolean)

Sets the Debug bool

Example

 plist.setDebug(false)

Plist.setWaitForDebugger(d:Boolean)

Sets the WaitForDebugger bool

Example

 plist.setWaitForDebugger(false)

Plist.setAbandonProcessGroup(d:Boolean)

Sets the AbandonProcessGroup bool

Example

 plist.setAbandonProcessGroup(false)

Plist.setLowPriorityIO(d:Boolean)

Sets the LowPriorityIO bool

Example

 plist.setLowPriorityIO(false)

Plist.setLaunchOnlyOnce(d:Boolean)

Sets the LaunchOnlyOnce bool

Example

 plist.setLaunchOnlyOnce(true)

Plist.setLabel(label:String)

Sets the Label field

Example

 plist.setLabel('com.curapps.test')

Plist.setProgram(program:String)

Sets the Program string

Example

 plist.setProgram('/usr/local/bin/node')

Plist.setUserName(username:String)

Sets the UserName string

Example

 plist.setUserName('evan')

Plist.setGroupName(groupname:String)

Sets the GroupName string

Example

 plist.setGroupName('admin')

Plist.setLimitLoadToSessionType(sessiontype:String)

Sets the LimitLoadToSessionType string

Example

 plist.setLimitLoadToSessionType('Aqua')

Plist.setStdErrPath(p:String)

Sets the StandardErrorPath string

Example

 plist.setStdErrPath('/Users/evan/Desktop/err.log')

Plist.setStdOutPath(p:String)

Sets the StandardOutPath string

Example

 plist.setStdOutPath('/Users/evan/Desktop/out.log')

Plist.setStdInPath(s:String)

Sets the StandardInPath string

Example

 plist.setStdInPath('/Users/evan/Desktop/in')

Plist.setRootDir(dir:String)

Sets the RootDirectory string

Example

 plist.setRootDir('/Users/evan/Desktop/test')

Plist.setWorkingDir(dir:String)

Sets the WorkingDirectory string

Example

 plist.setWorkingDir('/Users/evan/Desktop/test')

Plist.setProcessType(s:String)

Sets the ProcessType string

Example

 plist.setProcessType('Background')

Plist.setUmask(umask:Number)

Sets the Umask number

Example

 plist.setUmask(501)

Plist.setTimeOut(to:Number)

Sets the TimeOut number

Example

 plist.setTimeOut(30)

Plist.setExitTimeOut(to:Number)

Sets the ExitTimeOut number

Example

 plist.setExitTimeOut(30)

Plist.setThrottleInterval(throttle:Number)

Sets the ThrottleInterval number

Example

 plist.setThrottleInterval(300)

Plist.setStartInterval(i:Number)

Sets the StartInterval number

Example

 plist.setStartInterval(30)

Plist.setNice(i:Number)

Sets the Nice number

Example

 plist.setNice(19)

Plist.setProgramArgs(args:Array|String|Number|Object)

Sets the ProgramArguments array

Example

 var args = [
     '/usr/local/bin/node'
   , '/Users/evan/Desktop/test/app.js'
 ]
 plist.setProgramArgs(args)

Plist.setLimitLoadToHosts(hosts:Array|String|Number)

Sets the LimitLoadToHosts array

Example

 var hosts = ['127.0.0.1']
 plist.setLimitLoadToHosts(hosts)

Plist.setLimitLoadFromHosts(hosts:Array|String|Number)

Sets the LimitLoadFromHosts array

Example

 var hosts = ['127.0.0.1']
 plist.setLimitLoadFromHosts(hosts)

Plist.setWatchPaths(p:Array|String|Number|Object)

Sets the WatchPaths array

Example

 var p = '/Users/evan/Desktop/test/apps'
 plist.setWatchPaths(p)

Plist.setQueueDirectories(d:Array|String|Number|Object)

Sets the QueueDirectories array

Example

 var dirs = ['/Users/evan/Desktop/test/apps']
 plist.setQueueDirectories(dirs)

Plist.setEnvVar(obj:Object)

Sets the EnvironmentVariables object

Example

 var env = { NODE_ENV: 'test' };
 plist.setEnvVar(env)

Plist.setSoftResourceLimits(obj:Object)

Sets the SoftResourceLimits object

Example

 var res = { 'NumberOfFiles': 10000 }
 plist.setSoftResourceLimits(res)

Plist.setHardResourceLimits(obj:Object)

Sets the HardResourceLimits object

Example

 var res = { 'NumberOfFiles': 10000 }
 plist.setHardResourceLimits(res)

Plist.setKeepAlive(keepalive:Boolean|String|Number|Object)

Sets the KeepAlive value

Examples

 plist.setKeepAlive(true)
 var opts = { SuccessfulExit: false }
 plist.setKeepAlive(opts)

Plist.deleteStartCalendarInterval()

Removes the StartCalendarInterval object/array

Example

 plist.deleteStartCalendarInterval()

Plist.addCalendarInterval(o:Object)

Adds a Dictionary for the StartCalendarInterval

Example

 // Run at minute 1 of every hour
 var obj = { Minute: 1 }
 plist.addCalendarInterval(obj)

Plist.build(obj:Object)

Builds the actual plist object into a string

Example

 var contents = plist.build()

Plist.reset()

Wipes the slate clean

Example

 plist.reset()