public
Description: A tool for controlling and configuring Merb applications
Homepage: http://crazycool.co.uk/2008/04/16/manage-your-merb
Clone URL: git://github.com/eldiablo/merb-manage.git
Search Repo:
tidied up the codebase a bit; also added the daemonize (-d) flag if no 
servers are specified within the Merb config; also added group and logging 
to sample config
eldiablo (author)
Wed Apr 16 01:22:53 -0700 2008
commit  80c1fc7aa6aa461deace70ec8dd49d20200cf353
tree    81395ed1dc46ff3504440ca1af9d252f01558cce
parent  3d7fe8de43fa491ecef542044033a3c8f21e27b4
...
1
...
 
0
@@ -1 +0,0 @@
0
-pkg
0
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
...
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
0
@@ -1 +1,38 @@
0
-merb-manage: a tool for controlling and configuring Merb applications
0
\ No newline at end of file
0
+merb-manage: a tool for controlling and configuring Merb applications
0
+
0
+Usage:
0
+
0
+ merb-manage-ctl [start|stop|restart] (-c CONFIG_DIR)
0
+ start: starts any instances of Merb applications configured within the CONFIG_DIR (defaults to /etc/merb-manage)
0
+ stop: stops any instances of Merb applications configured within the CONFIG_DIR
0
+ restart: stops, then starts any instances of Merb applications configured within the CONFIG_DIR
0
+
0
+ merb-manage [start|stop|restart]
0
+ this script can be used as a startup script, for example within /etc/init.d, to call out to merb-manage-ctl to start Merb applications when a server starts
0
+
0
+
0
+Configuration:
0
+
0
+ YAML configuration files define the Merb application settings for merb-manage. Generally you can store the configuration within the config directory of your Merb application (config/merb-manage.yml), and then symlink this to a file within the configuration directory (/etc/merb-manage/myapp.yml).
0
+
0
+ Configuration might look like the following:
0
+
0
+ path: /var/www/sample_app
0
+ adapter: thin
0
+ environment: production
0
+ port: 5000
0
+ servers: 3
0
+ user: www-data
0
+ group: www-data
0
+ logging: info
0
+
0
+ Here are the supported parameters:
0
+ user: the user that the application should run as - if specified, the Merb application is started with an su USER -c "COMMAND", and the user is passed through to the Merb startup command
0
+ group: the group that the application runs under, passed through to the Merb startup command
0
+ adapter: the web application server adapter, such as mongrel, thin etc - anything that your installation of Merb supports
0
+ environment: the Merb environment to run as, development, test or production
0
+ servers: the amount of servers to start (for clustering/load balancing etc)
0
+ port: the port to start the Merb application on (in the case of multiple servers, the ports will be sequential from the port specified, i.e. servers set to 3, with port set to 5000, would start the application on 5000, 5001 and 5002)
0
+ logging: the logging level to pass through to Merb - debug, info, warn, error and fatal
0
+
0
+ Most of these options can be left off if you simply want the Merb defaults - if "servers" isn't specified however, then Merb will be passed the "-d" flag to ensure that the single Merb server will run in daemonized mode.
0
\ No newline at end of file
...
9
10
11
12
 
13
14
15
 
16
17
 
18
19
20
...
9
10
11
 
12
13
14
 
15
16
 
17
18
19
20
0
@@ -9,12 +9,12 @@ require "rake/gempackagetask"
0
 # Define the merb-manage gem spec
0
 spec = Gem::Specification.new do |s|
0
   s.name = "merb-manage"
0
- s.version = "0.2"
0
+ s.version = "0.3"
0
   s.author = "El Draper"
0
   s.email = "el@eldiablo.co.uk"
0
- s.homepage = "http://crazycool.co.uk/blog/tags/merb-manage"
0
+ s.homepage = "http://github.com/eldiablo/merb-manage"
0
   s.platform = Gem::Platform::RUBY
0
- s.summary = "Provides easy configuration of Merb applications, including multiple servers and different adapters"
0
+ s.summary = "Provides easy configuration and management of Merb applications, including multiple servers and different adapters"
0
   s.files = FileList["{bin,config,resources}/**/*"].to_a
0
   s.executables << "merb-manage-ctl"
0
   s.add_dependency("merb", ">= 0.9.2")
...
12
13
14
15
 
16
17
18
...
40
41
42
 
43
44
45
46
47
48
49
...
52
53
54
55
 
56
57
58
...
68
69
70
71
 
72
73
...
12
13
14
 
15
16
17
18
...
40
41
42
43
44
45
46
 
47
48
49
...
52
53
54
 
55
56
57
58
...
68
69
70
 
71
72
73
0
@@ -12,7 +12,7 @@ configuration_directory = "/etc/merb-manage"
0
 # Validate
0
 raise "No arguments specified!" if ARGV.length == 0
0
 
0
-#See if there is a -c argument
0
+# See if there is a -c argument
0
 if ARGV.include?("-c")
0
   # Attempt to grab the specified config directory
0
   config = ARGV[ARGV.index("-c") + 1]
0
@@ -40,10 +40,10 @@ def start(yml)
0
   command += "-a #{yml['adapter']} " unless yml["adapter"].nil?
0
   command += "-e #{yml['environment']} " unless yml["environment"].nil?
0
   command += "-c #{yml['servers']} " unless yml["servers"].nil?
0
+ command += "-d " if yml["servers"].nil?
0
   command += "-p #{yml['port']} " unless yml["port"].nil?
0
   command += "-l #{yml['logging']} " unless yml["logging"].nil?
0
   command = "su #{yml['user']} -c \"#{command}\"" unless yml["user"].nil?
0
-
0
   `#{command}`
0
 end
0
 
0
@@ -52,7 +52,7 @@ def stop(yml)
0
   `merb -m #{yml["path"]} -k all`
0
 end
0
 
0
-# Evaluate the action being requested
0
+# Evaluate and execute the action being requested
0
 case ARGV[0]
0
   when "start":
0
     each_config(configuration_directory) do |yml|
0
@@ -68,5 +68,5 @@ case ARGV[0]
0
       stop(yml)
0
     end
0
 else
0
- raise "Argument `#{ARGV[0]}` not recognised!"
0
+ puts "Usage: merb-manage-ctl {start|stop|restart} (-c CONFIG_DIR)"
0
 end
0
\ No newline at end of file
...
4
5
6
7
8
 
 
9
...
4
5
6
 
7
8
9
10
0
@@ -4,4 +4,5 @@ environment: production
0
 port: 5000
0
 servers: 3
0
 user: www-data
0
-group: www-data
0
\ No newline at end of file
0
+group: www-data
0
+logging: info
0
\ No newline at end of file
...
4
5
6
7
 
8
9
10
 
11
12
13
...
16
17
18
19
 
20
21
22
23
24
 
25
26
27
28
 
29
30
31
32
 
33
34
35
36
 
37
38
39
...
4
5
6
 
7
8
9
 
10
11
12
13
...
16
17
18
 
19
20
21
22
23
 
24
25
26
27
 
28
29
30
31
 
32
33
34
35
 
36
37
38
39
0
@@ -4,10 +4,10 @@
0
 #
0
 # merb-manage      Startup script for Merb applications, utilising merb-manage-ctl
0
 #
0
-# Can be used within /etc/init.d to ensure Merb apps fire back up after a reboot
0
+# Can be used as a startup script to ensure Merb apps fire back up after a reboot (such as within /etc/init.d)
0
 #
0
 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local:/usr/local/sbin:/usr/local/bin
0
-CONF_DIR=/etc/merb-manage
0
+MERB_MANAGE_CONF_DIR=/etc/merb-manage
0
 
0
 # Default return value
0
 RETVAL=0
0
@@ -16,24 +16,24 @@ RETVAL=0
0
 which merb-manage-ctl >/dev/null || exit 0
0
 
0
 # Validate config directory
0
-[ -d "$CONF_DIR" ] || exit 0
0
+[ -d "$MERB_MANAGE_CONF_DIR" ] || exit 0
0
 
0
 # Evaluate command
0
 case "$1" in
0
     start)
0
- merb-manage-ctl start -c $CONF_DIR
0
+ merb-manage-ctl start -c $MERB_MANAGE_CONF_DIR
0
       RETVAL=$?
0
   ;;
0
     stop)
0
- merb-manage-ctl stop -c $CONF_DIR
0
+ merb-manage-ctl stop -c $MERB_MANAGE_CONF_DIR
0
       RETVAL=$?
0
   ;;
0
     restart)
0
- merb-manage-ctl restart -c $CONF_DIR
0
+ merb-manage-ctl restart -c $MERB_MANAGE_CONF_DIR
0
       RETVAL=$?
0
   ;;
0
     *)
0
- echo "Usage: merb-manage-ctl {start|stop|restart}"
0
+ echo "Usage: merb-manage {start|stop|restart}"
0
       exit 1
0
   ;;
0
 esac

Comments

    No one has commented yet.