GithubHelp home page GithubHelp logo

lunchy's Introduction

lunchy

A friendly wrapper for launchctl. Start your agents and go to lunch!

Don't you hate OSX's launchctl? You have to give it exact filenames, the syntax is annoyingly different from Linux's, and it is overly verbose. It's just not a very developer-friendly tool.

Lunchy aims to be that friendly tool by wrapping launchctl and providing a few simple operations that you perform all the time:

  • ls [pattern]
  • start [pattern]
  • stop [pattern]
  • restart [pattern]
  • status [pattern]
  • install [file]
  • uninstall [pattern]
  • show [pattern]
  • edit [pattern]

where pattern is just a substring that matches the agent's plist filename. If you don't use a unique pattern, Lunchy will warn you of this and give you a list of the matching items instead.

So instead of:

launchctl load ~/Library/LaunchAgents/io.redis.redis-server.plist

you can do this:

lunchy start redis

and:

> lunchy ls
com.danga.memcached
com.google.keystone.agent
com.mysql.mysqld
io.redis.redis-server
org.mongodb.mongod

The original name was supposed to be launchy. Lunchy isn't a great name but gem names are like domains, most of the good ones are taken. :-(

Installation

Using RubyGems

gem install lunchy

Lunchy is written in Ruby because I'm a good Ruby developer and a poor Bash developer. Help is welcome.

Using Homebrew

brew install lunchy

Thanks

Thanks to all the individual contributors who've improved Lunchy, see credits in History.md.

Lunchy was written as part of my project time at Carbon Five. They're hiring if you love working on Ruby and open source.

About

lunchy's People

Contributors

a-chernykh avatar andyjeffries avatar bunnymatic avatar dzjuck avatar eddiezane avatar fhemberger avatar ho-ian avatar indirect avatar jc00ke avatar jnewland avatar jonpierce avatar jpsilvashy avatar koraktor avatar marshally avatar mperham avatar osaris avatar stve avatar vladimyr avatar whatcould avatar yokoto avatar zenspider 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lunchy's Issues

Bash completion

Can you add bash-completion support, for using Tab to autocomplete. That is very helpful when working on terminal.

nothing found to load

After installing redis via Homebrew (OS X 10.8), lunchy unable to load plist, unless I've loaded it manually with launchctl load -Fw ~/LaunchAgents/homebrew.mxcl.redis.plist. After that trick - lunchy working perfectly.

unable to launch

I've just installed and ran the ls command, this is what I get:

[richard@macpro ~]$ launchy ls
Unable to launch ls

Quick Curiosity/Discussion on — lunchy install [file]

Apologize, but 140 chars (twitter) wasn't enough to write my question...
@mperham / @eddiezane can you provide a quick confirmation for me?

lunchy install [file] does what exactly? seems to me https://github.com/eddiezane/lunchy/blob/master/lib/lunchy.rb#L55-L69 it either sym links or copies an agents plist file to either the users ~/Library/LaunchAgent or the systems /Library/LaunchAgent directory? Essentially a convenience method that does Step 6 in this how-to article??
Although, while researching where the CONFIG[:symlink] constant hash was defined I came across this comment (https://github.com/eddiezane/lunchy/blob/master/bin/lunchy#L48), which pretty much answers my question (I think)?

However, in what instances would I use this method? Perhaps if I compile and install from source a service? Is it simply what I referenced in that postgres article? A convenience method for cp?
Can you provide a [file] arg example where I would need Lunchy install? (I'd like to get apache2 deamonized and managed through Lunchy!) Guess that would involve writing a wrapper around apachectl amirite?

Btw. I love this little tool! Agree, odd name but whatevs! It's fuckin handy!

Services with partially common names

I cannot currently interact with the couchdb service because I have a couchdb-lucene service:

$> lunchy stop homebrew.mxcl.couchdb
Multiple daemons found matching 'homebrew.mxcl.couchdb'. You need to be more specific. Matches found are:
homebrew.mxcl.couchdb-lucene
homebrew.mxcl.couchdb

Can I suggest that if there is an exact match then it is assumed that is the one intended?

Proposal: Change `master` branch to `main`

Github and others have started moving away from master as the default branch name in favor of main.

I'd like to propose that we move this repo to follow this as well.

I'd submit a PR, but I believe this is more of a Github repo settings change.

Issue with similarly named scripts

Currently if you have a launchd script named foo and one named foo.bar, you cannot enable foo. Instead you get an error from here. This looks to be caused by not checking for more specific matches, rather than just the regex matches.

I'm happy to submit a patch to also do a check for equality, besides just regex, if you're open to it!

Root use?

Hi,

First of all, thanks for lunchy, i always use ctrl-R to find my previous launchctl calls, not remembering the arguments / plist paths :)
It's a great time savior...

Not an issue i guess, but more a howto / feature request. I have some services installed as root (like nginx on port 80) and I can't figure how to use lunchy as root.

I first tried sudo lunchy ls which fails because of missing rvm environment.
Then i tried sudo -E lunchy ls works but that brings the current user services list, not the root one.
I also tried the rvm way, rvmsudo lunchy ls, same result as sudo -E.

I'm maybe missing something basic like a how to use a user rvm env installed gem as root, can you enlight me?

version 0.7.0 not on rubygems.org?

I see a version bump in the code (quite some time ago) but this version is not available on rubygems.org:

http://rubygems.org/gems/lunchy

% gem list -r | grep lunchy
lunchy (0.6.0 ruby)

Is 0.7.0 ready for release? I'd like to use it from another gem but am using unreleased features at the moment.

Converting to self-contained standalone?

I'm not much of a Ruby guy, but I was wondering how much work it would take to port this to something that could be installed via homebrew.

"brew install lunchy" will drive adoption in places that "gem install lunchy" will terrify people (namely: not ruby devs and who remember all too well the nightmare that CPAN wrought on systems). It doesn't seem that it would be too challenging, overall?

Needs a new release

There have been a few fixes incorporated since the initial 0.5.0 release (i.e. #16) that are not available if you're just doing a gem install lunchy.

Trouble running as non-root

with OSX Lion and RVM (ree), I'm getting this when I run lunchy as my normal user:

Bug: launchctl.c:2408 (24957):13: (dbfd = open(g_job_overrides_db_path, O_RDONLY | O_EXLOCK | O_CREAT, S_IRUSR | S_IWUSR)) != -1
launch_msg(): Socket is not connected

It goes away if I use sudo.

start/stop is not the same as load/unload

This is my case. I installed the PostgreSQL from Homebrew and made it as a service. But I don't want the service auto start when OS booting. Then I modified the plist and set KeepAlive and RunAtLoad to false. After that, I tried to start the service with lunchy start postgres, but it's not working. At first, I thought I made some mistakes in configuration. After several rounds test, I figured out launchctl start homebrew.mxcl.postgresql was working for me. Then I found lunchy use load/unload behind the start/stop command. IMO, maybe we should follow the launchctl's convention, make them corresponding.

Flag to install service from brew

I've been doing lunchy install -s $(brew --prefix redis)/*.plist quite a bit recently. We should have a flag that will do this for a brew formula.

-bash: lunchy: command not found

I'm realitivly new to mac os, so this is probably a simple question. I have tried both gem install lunchy, and sudo gem install lunchy, with the same results.

running ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]

Thanks,
Jason

no way to run a plist outside LaunchAgents

I'm not sure if I'm doing it wrong or if Lunchy doesn't handle that case...

I want to use Lunchy to start Redis using a plist file that's in /usr/local/Cellar/. I don't want to copy it to LaunchAgents, because it would be started automatically on startup, and I don't want it to run all the time. I want to run it only when I need it. I wanted to use Lunchy for that, but it seems it can only run files from LaunchAgents, which should already be running anyway.

It would be more useful if Lunchy looked for the plist files in some common locations, like /usr/local/Cellar/**. (Or do I just not understand how this all works?)

A per-project Lunchfile?

This isn't an "issue" so much as a thought.

So what if there was a Lunchfile
you could add to a project.

Then you could just say

$ lunchy .

and it would load the Lunchfile and start the relevant services?

eg.

matthew@RuPro:~/code/3rdhome$ cat Lunchfile 
# commands for lunchy
start mysql

Not sure how you could unload it.

eg. if two projects were running simultaneously, both using mysql.
how would you say "stop project 1, but keep mysql running for project 2"

probably best to ignore this
and just deal with starting the right services.

License missing from gemspec

Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec,

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Even for projects that already specify a license, including a license in your gemspec is a good practice, since it is easily
discoverable there without having to check the readme or for a license file.

For example, there is a License Finder gem to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough
issue that even Bundler now generates gems with a default 'MIT' license.

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file),
github has created a license picker tool.

In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally
looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :).

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue and let me know. In either case, I'll follow up. Thanks!

p.s. I've written a blog post about this project

install lunchy with brew

This is not an issue, just a suggestion. It would be really nice to be able to install lunchy with Homebrew.

brew install lunchy 

Know which .plist's are disabled

When you "lunchy start -w myservice" or "lunchy stop -w myservice" the state is saved for next boots. In the past days launchctel was adding a key to the .plist file with the value "Disabled", but since SnowLeopard the .plist file is not changed and it is store elsewhere.

As far as I know, launchctl does not offer a way to know if a .plist file is disabled or not for next boots and having to reboot is tedious... It would be great to have some way to see which .plists are disabled or not.

The "lunchy status" command seems the more appropiated place to me for showing it but since it uses the "launchctl list" output, it would be fair enough something like "lunchy disabled".

A link to an article that explains the new locations where the disabled keys are stored:
http://www.mactech.com/articles/mactech/Vol.25/25.10/2510MacEnterprise-SnowLeopard-launchdandLunch/index.html

installed lunchy,zsh error occurred

error message:
complete:13: command not found: compdef
lunchy version: Lunchy 0.10.4
zsh version: zsh 5.0.5 (x86_64-apple-darwin14.0)

in ~/.zshrc ,add the following code
LUNCHY_DIR=$(dirname gem which lunchy)/../extras
if [ -f $LUNCHY_DIR/lunchy-completion.zsh ]; then
. $LUNCHY_DIR/lunchy-completion.zsh
fi

Getting completion error when using zsh

So @osaris made a fix here #59 but as @Zhomart pointed out, we need to add -U as an option to autoload.

I can confirm adding -U makes it work. I am using zsh 5.0.8 (x86_64-apple-darwin14.3.0) and without the -U, I get:

bashcompinit:134: parse error near `|'
/Users/eumir/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/lunchy-0.10.3/lib/../extras/lunchy-completion.bash:18: command not found: complete

I don't know much about zsh (I only use it because of yadr) but from what I read here: http://zsh.sourceforge.net/Doc/Release/Functions.html#Autoloading-Functions it is needed because:

The usual alias expansion during reading will be suppressed if the autoload builtin 
or its equivalent is given the option -U. This is recommended for the use of
functions supplied with the zsh distribution. Note that for functions 
precompiled with the zcompile builtin command the flag -U must 
be provided when the .zwc file is created, as the corresponding 
information is compiled into the latter.

Can't select daemon

I can't select daemon because there two starts with same substring.

 german$ lunchy restart syncthing
Multiple daemons found matching 'syncthing'. You need to be more specific. Matches found are:
homebrew.mxcl.syncthing-inotify
homebrew.mxcl.syncthing
Multiple daemons found matching 'syncthing'. You need to be more specific. Matches found are:
homebrew.mxcl.syncthing-inotify
homebrew.mxcl.syncthing
 german$ lunchy restart homebrew.mxcl.syncthing
Multiple daemons found matching 'homebrew.mxcl.syncthing'. You need to be more specific. Matches found are:
homebrew.mxcl.syncthing-inotify
homebrew.mxcl.syncthing
Multiple daemons found matching 'homebrew.mxcl.syncthing'. You need to be more specific. Matches found are:
homebrew.mxcl.syncthing-inotify
homebrew.mxcl.syncthing

Add `/System/Library/LaunchAgents` dir

I'm new to this stuff -- any particular reason why system LaunchDaemons is available, but not LaunchAgents? Would like to use lunchy to restart the dock :)

problems interpreting arguments

I've got some strange problems running launchy that I suspect are related.

Running Launchy without any arguments errors, but should probably display help:

systems-samm ~ % launchy
ERROR: Failure in opening uri nil with options {}: undefined method `to_hash' for nil:NilClass
Try `launchy --help' for more information.

ls doesn't work - it looks like launchy thinks I'm passing in an application rather than an argument:

systems-samm ~ % launchy ls
ERROR: No application found to handle 'ls'

Help seems to work:

systems-samm ~ % launchy --help
Usage: launchy [options] thing-to-launch

Launch Options:
    -a, --application APPLICATION    Explicitly specify the application class to use in the launch
    -d, --debug                      Force debug. Output lots of information.
    -e, --engine RUBY_ENGINE         Force launchy to behave as if it was on a particular ruby engine.
    -n, --dry-run                    Don't launchy, print the command to be executed on stdout
    -o, --host-os HOST_OS            Force launchy to behave as if it was on a particular host os.

Standard Options:
    -h, --help                       Print this message.
    -v, --version                    Output the version of Launchy

Version info:

systems-samm ~ % launchy -v
Launchy version 2.4.2
systems-samm ~ % gem --version
2.2.2
systems-samm ~ % ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]
systems-samm ~ % zsh --version
zsh 5.0.7 (x86_64-apple-darwin14.0.0)

(Gem::LoadError)

/Users/python/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:315:in to_specs': Could not find 'lunchy' (>= 0) among 15 total gem(s) (Gem::LoadError) Checked in 'GEM_PATH=/var/root/.gem/ruby/2.2.0:/Users/python/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0', executegem envfor more information from /Users/python/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/dependency.rb:324:into_spec'
from /Users/python/.rvm/rubies/ruby-2.2.0/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_gem.rb:64:in gem' from /Users/python/.rvm/gems/ruby-2.2.0/bin/lunchy:22:in

'
from /Users/python/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in eval' from /Users/python/.rvm/gems/ruby-2.2.0/bin/ruby_executable_hooks:15:in'

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.