Skip to content

Commit

Permalink
add about page
Browse files Browse the repository at this point in the history
  • Loading branch information
max-mapper committed Mar 21, 2015
1 parent 4f48715 commit c4f0f11
Show file tree
Hide file tree
Showing 17 changed files with 142 additions and 31 deletions.
43 changes: 43 additions & 0 deletions about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<header class="bar bar-nav">
<a href="/">
<button class="btn btn-link btn-nav pull-left">
<span class="icon icon-left-nav"></span>
Back
</button>
</a>
<h1 class="title">About Monu</h1>
</header>
<div class="content" style="padding: 40px 20px">
<h5>What is Monu</h5>
<p>Monu is an open source process monitoring application for Mac OS. You can configure Monu to launch programs, and when Monu starts up it will start them. Additionally, it will monitor the processes and restart them if they crash.</p>
<h5>How to use Monu</h5>
<p>To configure Monu, click 'Open Config Folder' and open 'config.json' in a text editor. When you save and return to Monu your new configuration will be automatically loaded.</p>
<p>Be sure your JSON syntax is valid when editing the configuration. Here are supported options. These should be added as top level key/value pairs to 'config.json':</p>
<ul>
<li><b>processes</b> the processes to run (see below)</li>
<li><b>logs</b> the directory to store logs in (default config/pids)</li>
<li><b>pids</b> the directory to store PIDs in (default config/logs)</li>
<li><b>on-error</b> a command to run when a process cannot start (default none)</li>
<li><b>on-restart</b> a command to run when a process restarts (default none)</li>
<li><b>sleep</b> sleep seconds before re-executing (default 1)</li>
<li><b>attempts</b> restart attempts within 60 seconds before stopping app (default 10)</li>
<li><b>prefix</b> add a string prefix to the log (default none)</li>
</ul>
<h5>Adding Processes</h5>
<p>In the 'config.json' file add processes to the 'processes' key. The key must be a name (lowercase letters and hypens) and the value must be the launch command. For example:<p>
<pre><code>{
"logs": "./logs",
"pids": "./pids",
"processes": {
"web-1": "http-server . -p 8081",
"web-2": "http-server . -p 8082",
"web-3": "http-server . -p 8083"
}
}</code></pre>
<h5>Launch on Startup</h5>
<p>When you open Monu.app, it will start all configured processes.</p>
<p>If you would like Monu.app to start when your Mac starts up, got to <b>System Preferences &gt; Users and Groups</b> and add Monu.app to <b>Login Items</b> for your User.</p>
<h5>About</h5>
<p>Monu is a portmanteau of 'monitor' and 'menu'. It has two C/C++ dependencies, Atom Shell and the Mon process monitor.</p>
<p>If you find bugs, want to send pull requests, or want the source code visit https://github.com/maxogden/monu</p>
</div>
7 changes: 7 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"logs": "./logs",
"pids": "./pids",
"processes": {

}
}
9 changes: 9 additions & 0 deletions config/logs/web-1.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Starting up http-server, serving . on port: 8080
Hit CTRL-C to stop the server
mon : write mon pid to /Users/maxogden/src/js/monu/config/pids/web-1.mon.pid
mon : child 13973
mon : write pid to /Users/maxogden/src/js/monu/config/pids/web-1.pid
mon : shutting down
mon : kill(-13972, 3)
mon : waiting for exit
mon : bye :)
9 changes: 9 additions & 0 deletions config/logs/web-2.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Starting up http-server, serving . on port: 8086
Hit CTRL-C to stop the server
mon : write mon pid to /Users/maxogden/src/js/monu/config/pids/web-2.mon.pid
mon : child 13975
mon : write pid to /Users/maxogden/src/js/monu/config/pids/web-2.pid
mon : shutting down
mon : kill(-13974, 3)
mon : waiting for exit
mon : bye :)
9 changes: 9 additions & 0 deletions config/logs/web-3.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Starting up http-server, serving . on port: 8090
Hit CTRL-C to stop the server
mon : write mon pid to /Users/maxogden/src/js/monu/config/pids/web-3.mon.pid
mon : child 13977
mon : write pid to /Users/maxogden/src/js/monu/config/pids/web-3.pid
mon : shutting down
mon : kill(-13976, 3)
mon : waiting for exit
mon : bye :)
1 change: 1 addition & 0 deletions configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<style type="text/css">
/* overrides */
.content .table-view { margin: 0 !important; }
ul, code {font-size: 14px; color: #777;}
</style>
</head>
<body>
Expand Down
16 changes: 14 additions & 2 deletions configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Ractive.DEBUG = false

var templates = {
configure: fs.readFileSync('./configure.tmpl').toString(),
detail: fs.readFileSync('./detail.tmpl').toString()
detail: fs.readFileSync('./detail.tmpl').toString(),
about: fs.readFileSync('./about.html').toString()
}

var state = {}
Expand All @@ -25,6 +26,10 @@ $(document).on('click', '.btn.quit', function(e) {
ipc.send('terminate')
})

$(document).on('click', '.btn.open-dir', function(e) {
ipc.send('open-dir')
})

ipc.on('got-all', function gotAll (data) {
data = data.map(function map (d) {
if (d.uptime) {
Expand All @@ -41,7 +46,9 @@ ipc.on('got-all', function gotAll (data) {
d.message = "Not Running"
return d
})
state.configure.set({items: data})
var obj = {items: data}
if (data.length > 0) obj.hasProcesses = true
state.configure.set(obj)
})

ipc.on('got-one', function gotOne (data) {
Expand All @@ -64,12 +71,17 @@ var routes = {
ipc.once('status', function() {
next()
})
},
about: function(ctx, next) {
ctx.template = templates.about
state.about = render(ctx, {})
}
}

// set up routes
page('/', routes.configure)
page('/detail/:name', routes.detail)
page('/about', routes.about)

// initialize router
page.start()
Expand Down
17 changes: 17 additions & 0 deletions configure.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
{{#items}}
<li class="table-view-cell media"><a href="/detail/{{name}}" class="navigate-right"><span class="media-object pull-left icon icon-gear"></span> {{name}} <button class="btn {{classes}}">{{message}}</button></a></li>
{{/items}}
{{^items}}
<li class="table-view-cell table-view-divider">Processes</li>
<li class="table-view-cell media">No Processes Configured</li>
{{/items}}
<li class="table-view-cell table-view-divider">Actions</li>
{{#hasProcesses}}
<li class="table-view-cell media">
<a rel="external" class="processAction" data-action="startAll">
<span class="media-object pull-left icon icon-play"></span>
Expand All @@ -27,8 +32,20 @@
</div>
</a>
</li>
{{/hasProcesses}}
<li class="table-view-cell media">
<a href="/about">
<span class="media-object pull-left icon icon-search"></span>
<div class="media-body">
About
</div>
</a>
</li>
</ul>
<div class="bar bar-standard bar-footer">
<button class="btn pull-left open-dir">
Open Config Folder
</button>
<button class="btn pull-right quit">
Quit
</button>
Expand Down
Binary file added images/Icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/Status.png
Binary file not shown.
Binary file removed images/[email protected]
Binary file not shown.
Binary file removed images/StatusHighlighted.png
Binary file not shown.
Binary file removed images/[email protected]
Binary file not shown.
50 changes: 33 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var path = require('path')
var child = require('child_process')

var app = require('app')
var Menu = require('menu')
Expand Down Expand Up @@ -26,28 +27,15 @@ app.on('ready', function() {
e.preventDefault()
})

var template = []

var iconPath = path.join(__dirname, 'images', 'Status.png')
var configFile = './test/config.json'
var conf = require(configFile)
var dir = path.dirname(configFile)

conf.exec = {cwd: path.resolve(dir)}
conf.logs = path.resolve(path.join(dir, conf.logs || 'logs'))
conf.pids = path.resolve(path.join(dir, conf.pids || 'pids'))

mkdir(conf.logs)
mkdir(conf.pids)

conf.mon = path.join(__dirname, 'mon')
var conf = loadConfig()

// start all once
start([], function started (err) {
if (err) return console.log("error starting processes: " + err.message)
console.log("started all processes")
})


var iconPath = path.join(__dirname, 'images', 'Icon.png')
icon = new Tray(iconPath)

icon.on('clicked', function(e) {
Expand All @@ -60,6 +48,10 @@ app.on('ready', function() {
app.terminate()
})

ipc.on('open-dir', function openDir (ev) {
child.exec('open ' + conf.exec.cwd, function(err) {})
})

ipc.on('get-all', function getAll (ev, data) {
getStatus()
})
Expand All @@ -81,6 +73,29 @@ app.on('ready', function() {
}
})

function loadConfig() {
var configFile = './config/config.json'
var conf

try {
conf = JSON.parse(fs.readFileSync(configFile))
} catch (e) {
throw new Error('Invalid configuration file -- could not parse JSON')
}

var dir = path.dirname(configFile)

conf.exec = {cwd: path.resolve(dir)}
conf.logs = path.resolve(path.join(dir, conf.logs || 'logs'))
conf.pids = path.resolve(path.join(dir, conf.pids || 'pids'))

mkdir(conf.logs)
mkdir(conf.pids)

conf.mon = path.join(__dirname, 'mon')
return conf
}

function showConfigure() {
if (configure) {
getStatus()
Expand All @@ -104,7 +119,8 @@ app.on('ready', function() {
function getStatus(err, procName) {
if (err) throw err
if (!configure) return
debug('get proc status...')
debug('reload config, get proc status...')
conf = loadConfig()
var status = []
var group = new Mongroup(conf)
var procs = group.procs
Expand Down
9 changes: 0 additions & 9 deletions test/config.json

This file was deleted.

3 changes: 0 additions & 3 deletions test/config.mon

This file was deleted.

0 comments on commit c4f0f11

Please sign in to comment.