Skip to content

Instantly share code, notes, and snippets.

@koki-h
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save koki-h/3463798154f64e6de1a4 to your computer and use it in GitHub Desktop.

Select an option

Save koki-h/3463798154f64e6de1a4 to your computer and use it in GitHub Desktop.
rubyのプロセスを立ち上げて自分はすぐに終了するシェルスクリプト (Mac用)
#!/bin/sh
#rubyのプロセスを立ち上げて自分はすぐに終了するシェルスクリプト。
#Macの場合、ファイル名の拡張子を*.commandにしておくとログイン時やダブルクリック時に実行できる
APP_HOME=`dirname $0`             #スクリプトのパスを取得する
cd $APP_HOME                 #rubyのスクリプトが存在するパスへ移動
bundle exec ruby daemon.rb >> debug.log & #最初から入っているrubyが動くはず。 bundlerは前もって自分で入れる必要がある。
killall Terminal #これがないとスクリプトが終了してもターミナルが開きっぱなしになる。他にターミナルが立ち上がっている場合はヤバイ。
#最後のkillallはやめて、ターミナルの環境設定からシェルの終了時にウインドウを閉じる設定をしたほうがいいかもしれない。
# http://www.monochrome-photo.info/?p=9251
#起動時にスクリプトを実行する方法
# http://qiita.com/flashingwind/items/0cdcefc5aa4f0acb35f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment