<commit_before># nac

nac is a simple app control and monitoring daemon written in node

Unlike other process monitors, nac doesn't allow for random spawning and
adding of processes. Instead, nac expects you to add "apps" defined by their 
name and nacfile (procfile-like configuration files)

The nacfile allows you to specify many other things about the process,
such as arguments, environment variable configuration, working directory, 
custom scripts etc. 

nac remembers your apps and will restart them the next time its started.

nac is multi-server-aware which allows you to use it with parallel control 
tools such as [pssh](http://www.theether.org/pssh/),
[cssh](http://sourceforge.net/projects/clusterssh/),
[fabric](http://docs.fabfile.org/en/1.6/), or, in the future, **rnac**

nac can optionally be multi-user aware: a single daemon can run as root and 
all clients will talk to it. Apps however are run under the uid of the user 
that added the application, and each user can only control his own apps.

# quick start

Run the nac daemon.

    nacd --daemon

Create a simple [YAML](http://en.wikipedia.org/wiki/YAML) nacfile for your app 
in the same directory where your `app.js` resides:

```yaml
command: node
args: [app.js]
env: 
  NODE_ENV: production
  PORT: 5000
```

Add the nacfile to git, clone the app on your server and run the commands:

    $ nac myapp create ~/projects/myapp/nacfile.yaml
    myapp created (/home/spion/projects/myapp/nacfile.yaml)
    $ nac myapp start
    

# running as root

You can alternatively run the daemon as root. There is no need for concern - it
will run apps under the priviledges of the user that added them (by setting 
the uid and gid). Users can only administer the apps they've added themselves.
    
    su root; nacd --daemon

**Warning!** The root daemon will not read the apps that were added to existing
user daemons. Users will need to re-add their apps.

# other configuration options

There are two types of configuration files in nac:

* app configuration (nacfile)
* server daemon configuration (nacd.yaml)

### nacfile

Here is a complete example nacfile:

```yaml
name: myapp
# command to execute. It has to be executable: if using a JS file directly,
# use chmod +x file.js first and add a shebang line at the top containing:
# #!/usr/bin/env node 
command: ./myapp-cluster.js
# working dir relative to the nacfile
cwd: .

# extra arguments to add: either an array
args:
  - first
  - '--other'<commit_msg>(minor) fix readme instructions<commit_after># nac

nac is a simple app control and monitoring daemon written in node

Unlike other process monitors, nac doesn't allow for random spawning and
adding of processes. Instead, nac expects you to add "apps" defined by their 
name and nacfile (procfile-like configuration files)

The nacfile allows you to specify many other things about the process,
such as arguments, environment variable configuration, working directory, 
custom scripts etc. 

nac remembers your apps and will restart them the next time its started.

nac is multi-server-aware which allows you to use it with parallel control 
tools such as [pssh](http://www.theether.org/pssh/),
[cssh](http://sourceforge.net/projects/clusterssh/),
[fabric](http://docs.fabfile.org/en/1.6/), or, in the future, **rnac**

nac can optionally be multi-user aware: a single daemon can run as root and 
all clients will talk to it. Apps however are run under the uid of the user 
that added the application, and each user can only control his own apps.

# quick start

Run the nac daemon.

    nacd --daemon

Create a simple [YAML](http://en.wikipedia.org/wiki/YAML) nacfile for your app 
in the same directory where your `app.js` resides:

```yaml
command: node
args: [app.js]
env: 
  NODE_ENV: production
  PORT: 5000
```

Add the nacfile to git, clone the app on your server and run the commands:

    $ nac myapp create ~/projects/myapp/nacfile.yaml
    myapp created (/home/spion/projects/myapp/nacfile.yaml)
    $ nac myapp start
    

# running as root

You can alternatively run the daemon as root. There is no need for concern - it
will run apps under the priviledges of the user that added them (by setting 
the uid and gid). Users can only administer the apps they've added themselves.
    
    su root
    nacd --daemon

**Warning!** The root daemon will not read the apps that were added to existing
user daemons. Users will need to re-add their apps.

# other configuration options

There are two types of configuration files in nac:

* app configuration (nacfile)
* server daemon configuration (nacd.yaml)

### nacfile

Here is a complete example nacfile:

```yaml
name: myapp
# command to execute. It has to be executable: if using a JS file directly,
# use chmod +x file.js first and add a shebang line at the top containing:
# #!/usr/bin/env node 
command: ./myapp-cluster.js
# working dir relative to the nacfile
cwd: .

# extra arguments to add: either an array
args:
  - first
  - '--other'
{'fraction_non_alphanumeric': 0.07516536380036079, 'fraction_numerical': 0.0024052916416115455, 'mean_word_length': 3.7888675623800383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1386134', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1468, 'n_words': 712}