Coder Social home page Coder Social logo

max-mapper / monu Goto Github PK

View Code? Open in Web Editor NEW
1.1K 36.0 78.0 470 KB

menubar process monitor mac app [ALPHA]

Home Page: https://github.com/maxogden/monu/releases

License: BSD 2-Clause "Simplified" License

HTML 5.06% JavaScript 14.22% CSS 80.08% Makefile 0.64%

monu's Introduction

Monu

app.png

Monu is an open source process monitoring menu bar 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.

Monu is a portmanteau of 'monitor' and 'menu'. It has two C/C++ dependencies, Electron (which includes iojs) and the mon process monitor.

Monu is currently ALPHA STATUS and is intended for developers/early adopters.

To download the latest version visit the releases page

js-standard-style

Build Status

screenshot.png

How to use Monu

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.

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':

  • processes the processes to run (see below)
  • logs the directory to store logs in (default config/logs)
  • pids the directory to store PIDs in (default config/pids)
  • on-error a command to run when a process cannot start (default none)
  • on-restart a command to run when a process restarts (default none)
  • sleep sleep seconds before re-executing (default 1)
  • attempts restart attempts within 60 seconds before stopping app (default 10)
  • prefix add a string prefix to the log (default none)
Adding Processes

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:

{
  "logs": "./logs",
  "pids": "./pids",
  "processes": {
    "web-1": "http-server . -p 8081",
    "web-2": "http-server . -p 8082",
    "web-3": "http-server . -p 8083"
  }
}
Launch on Startup

When you open Monu.app, it will start all configured processes.

If you would like Monu.app to start when your Mac starts up, got to System Preferences > Users and Groups and add Monu.app to Login Items for your User.

Developing
npm install # installs electron and all the deps needed for monu
npm start # runs the app in the electron wrapper
npm run build # builds the mac app
Publishing

Before publishing, make sure that your repo is clean, and that you've created a tag for the latest commit. npm version [major|minor|patch] will do this for you, increasing the package.json version, creating a commit and adding a tag.

You should see something like this:

🐈  make publish
rm -rf Monu.app Monu.zip # prevent duplicates in the final bundle
npm run build

> [email protected] build /Users/maxogden/src/js/monu
> electron-packager . Monu --platform=darwin --arch=x64 --version=0.26.0 --ignore=node_modules/electron

Wrote new app to /Users/maxogden/src/js/monu/Monu.app
ditto -c -k --sequesterRsrc --keepParent Monu.app Monu.zip
npm run publish

> [email protected] publish /Users/maxogden/src/js/monu
> publish-release --template notes.md --assets Monu.zip

? Git Tag: v1.0.4
? Github repository owner: maxogden
? Github repository name: monu
? Release Name: Monu v1.0.4 Alpha

Uploading Monu.zip
[=================================================>] 100.0% (1.17 MB/s)
Done! Published at: https://github.com/maxogden/monu/releases/tag/v1.0.4

monu's People

Contributors

danielhusar avatar execat avatar mafintosh avatar marcbachmann avatar max-mapper avatar remixz avatar sindresorhus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

monu's Issues

bug: doesnt check if pid is already running

ran into a weird bug today where one of my .pid files in monu was 415, but I had another process running as pid 415 and monu couldn't kill it (it would give me a EPERM error and crash the app if I tried to kill/restart).

Killing process 415 (it was some other app I was running) fixed the issue. So to fix this I guess we should check on startup if the pid exists already?

Extend process execution definition

Currently there is simple format to add new process

  "processes": {
    "web-1": "cd /some/dir;sudo http-server . -p 8081",
  }

This is fine and it's good idea to keep definition simple, but to have config future proof, it would be great if monu can support also object as process definition.

  "processes": {
    "web-1": {
      "command": "http-server . -p 8081",
      "cwd": "/some/dir",
      "sudo": true
    }
  }

I took exec options as inspiration.

I think this will open more possibilities for adding new processes using interactive form rather than editing config file, also it will make config file much more readable.

What do you think?

windows/linux support

major issues:

  • I am not sure if mon works on windows. For linux, we would have to bundle prebuilt binaries. It is a small program so this isn't a big deal
  • We have to figure out this process but for windows and linux
  • Currently the taskbar and window positioning code assumes docking the window in the top-right corner of the screen. This may have to change

http-server: command not found

I'm trying to run globally-installed modules with monu, but it's failing. Here's my config.json:

{
  "logs": "./logs",
  "pids": "./pids",
  "processes": {
    "web-1": "http-server . -p 8081",
    "dot-clipboard": "dot-clipboard"
  }
}

The logs say:

http-server: command not found

I have http-server installed globally:

 » npm list -g http-server
/Users/z/.nvm/v0.10.38/lib
└── [email protected]

What should I do to help monu find it?

read PIDs even if they arent in config.json

say you add a process with name 'foo' to config.json, start it, and then go to config.json and remove 'foo'.

now you are in a state where there is a foo.pid and foo.mon.pid, and the foo processes are likely running

IMO any PIDs that aren't referenced by 'config.json' should get SIGTERM'd and then deleted

MacOS: make Monu center / align under toolbar icon

Currently, the toolbar UI is horizontally aligning itself a ways away from where the Monu icon is. This is a tad bit jarring UI wise... see pic:

screen shot 2015-03-24 at 3 21 50 pm

I'm not sure if Atom-Shell allows for centering it near the toolbar icon, or somehow that is impossible to figure out given current API.

I'll try to research this a little bit

A JavaScript error occured in the browser process

This happened when I shut down a process:

screen shot 2015-05-09 at 9 29 02 pm

Uncaught Exception:
Error: ENOENT: no such file or directory, unlink '/Users/z/Library/Application Support/Monu/data/pids/dot-clipboard.pid'
    at Error (native)
    at Object.fs.unlinkSync (fs.js:939:18)
    at Process.removePidfiles (/Applications/Monu.app/Contents/Resources/app/node_modules/mongroup/lib/process.js:101:6)
    at null._onTimeout (/Applications/Monu.app/Contents/Resources/app/node_modules/mongroup/lib/process.js:197:10)
    at Timer.listOnTimeout (timers.js:88:15)

Despite the error, the process did stop as intended.

sudo processes

I'd like to run a process as super user. Is it possible for monu to ask credentials to run processes that need special permissions?

show logs in app

add a button 'View Logs' on the process detail page that does the equivalent of tail -f in the webview for the app logs

automate Monu.app releases

here's the algorithm:

  • download atom-shell zip
  • extract
  • rename Atom.app to Monu.app
  • copy entire contents of monu source folder into Monu.app/Contents/Resources/app
  • rename CFBundleDisplayName, CFBundleIdentifier and CFBundleName fields in following plist files if they have these keys
  • Atom.app/Contents/Info.plist
  • Atom.app/Contents/Frameworks/Atom Helper.app/Contents/Info.plist
  • test that the app works by double clicking it
  • zip up Monu.app
  • upload to github releases

Disable autostart of processes

I'd like to disable the autostart for some processes.
Maybe we can expose it in the config:

// config.json
{
  "autostart": false,
  "logs": "./logs",
  "processes": {
    "redis": "redis-server",
    "postgres": "/usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres",
    "mongodb": "/usr/local/bin/mongod --config /usr/local/etc/mongod.conf --auth"
  }
}

A more flexible solution would be to use an object literal or array for the process definition.

// config.json
{
  "logs": "./logs",
  "pids": "./pids",
  "processes": {
    "redis": {
      "command": "redis-server",
      "autostart": true
    }
  }
}

integrate run-every

I found https://npmjs.org/run-every today, it is super simple and lets me do stuff like this in my config:

   "gititude-update": "run-every 600 bash -c \\\"gititude update || true\\\""

the bash -c part is just so I can do gititude update || true which makes it always exit with 0 so that run-every won't terminate due to non-zero exit code in case gititude update exits with non-zero

would be cool to integrate run-every into monu so you can do stuff like this easily in your config without the bash hax

support installing/running npm bins

would be super cool if you could somehow easily install bins from npm

for example, if you could click a '+' button in the app, type a npm module name in, hit 'install and save as a process' and then it would automatically do npm install in the background, and update your config to have the new app added

load PATH of mac user

when you run atom-shell index.js you can do e.g. require('child_process').exec('foo') and if foo is in your PATH it will find it.

but when you run it by double clicking Monu.app it says 'command not found: foo'. gotta figure this out :(

syntax error when using commands

I'm trying to use this in a simple

cd ~/Projects/instant-pages && spring rails s

But spring command is not found.
This has something to do with the path.
When I cd into the folder on my computer, rvm does some magic to load the right ruby version, along with the gem commands (spring is a gem)

/Users/amirsharif/.rvm/gems/ruby-2.2.1/bin/bundle

I think some of that magic is in

/Users/amirsharif/.rvm/scripts/cli

But using source /Users/amirsharif/.rvm/scripts/cli makes the shell have a bunch of syntax errors.
But it works fine in my terminal.
My default shell is zsh if that makes a difference.

Processes die ever since I upgraded to 1.0.7.

Logs just says:

mon : child 983
mon : write pid to /Users/ian/Library/Application Support/Monu/data/pids/redis.pid
mon : exit(127)

The commands execute fine if I run them manually and this is happening on 2 of my computers. I tried restoring the old version, but got the same issue. My config file looks like:

{
  "logs": "./logs",
  "pids": "./pids",
  "processes": {
    "redis": "redis-server",
    "postgres": "postgres -D /usr/local/var/postgres"
  }
}

Any ideas? Thanks.

why electron ?

This looks interesting but the first I noticed when I started it is that it use ~40MB of memory which is quite a lot of for a small utility sitting on the menubar :(

This makes me curious did you go with electron for the ease of use ? for javascript ?

escape quotes in commands

If you add to your config e.g. bash -c "echo foo", it gets turned into mon "bash -c "echo foo"" which means the inner quotes essentially get ignored and the running process will look like mon bash -c echo foo, when it should look like mon bash -c "echo foo".

The fix is to escape the inner quotes, the user can do this manually but I think we should probably do this for them. I wonder if it is as simple as simply replacing " with \"?

Javascript Error in main process on startup

TypeError: Cannot read property 'length' of null
    at SyncWriteStream.write (fs.js:2059:38)
    at Object.execFileSync (child_process.js:494:20)
    at Object.module.(anonymous function) [as execFileSync] (ATOM_SHELL_ASAR.js:162:18)
    at pathFromShellSync (/Applications/Monu.app/Contents/Resources/app/node_modules/fix-path/node_modules/shell-path/index.js:51:28)
    at Function.module.exports.sync (/Applications/Monu.app/Contents/Resources/app/node_modules/fix-path/node_modules/shell-path/index.js:33:11)
    at module.exports (/Applications/Monu.app/Contents/Resources/app/node_modules/fix-path/index.js:9:31)
    at Object.<anonymous> (/Applications/Monu.app/Contents/Resources/app/index.js:13:20)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.