diff options
author | rautenberg <rautenberg@in-silico.ch> | 2012-11-08 12:42:13 +0100 |
---|---|---|
committer | rautenberg <rautenberg@in-silico.ch> | 2012-11-08 12:42:13 +0100 |
commit | be296777c1368b36d1f8c52192edd0eff58b7f9f (patch) | |
tree | ffe77a698a8a0a28ad6311374df964a85bd118e2 | |
parent | 3727ceb973e075d13cba1216d40b7468b833171d (diff) |
initial unicorn init script description
-rw-r--r-- | _posts/2012-10-08-set-up-virtual-machine-in-proxmox-virtual-environment.md | 8 | ||||
-rw-r--r-- | _posts/2012-11-07-unicorn-init-script-with-restart-and-upgrade.md | 48 |
2 files changed, 52 insertions, 4 deletions
diff --git a/_posts/2012-10-08-set-up-virtual-machine-in-proxmox-virtual-environment.md b/_posts/2012-10-08-set-up-virtual-machine-in-proxmox-virtual-environment.md index 468f27b..c9a44be 100644 --- a/_posts/2012-10-08-set-up-virtual-machine-in-proxmox-virtual-environment.md +++ b/_posts/2012-10-08-set-up-virtual-machine-in-proxmox-virtual-environment.md @@ -1,9 +1,9 @@ --- layout: post title: "Set Up Virtual Machine in Proxmox Virtual Environment" -description: "" -category: -tags: [] +description: "Short description of a scenario " +category: server +tags: [Setup] --- {% include JB/setup %} @@ -47,7 +47,7 @@ dmz and network is defined in `/etc/shorewall/interfaces` ##Apache 2 Setup -Let's supose to setup a website mysite.net at the virtual machine 10.0.0.101. Edit `/etc/apache2/sites-available/mysite` +Let's suppose to setup a website mysite.net at the virtual machine 10.0.0.101. Edit `/etc/apache2/sites-available/mysite` <VirtualHost *:80> ProxyPreserveHost On diff --git a/_posts/2012-11-07-unicorn-init-script-with-restart-and-upgrade.md b/_posts/2012-11-07-unicorn-init-script-with-restart-and-upgrade.md new file mode 100644 index 0000000..833bbde --- /dev/null +++ b/_posts/2012-11-07-unicorn-init-script-with-restart-and-upgrade.md @@ -0,0 +1,48 @@ +--- +layout: post +title: "Unicorn Init Script with restart and upgrade" +description: "" +category: server +tags: [Setup] +--- +{% include JB/setup %} + +##Restarting Seamlessly Unicorn Master Processes + +Therefore we use a `before_fork` Proc in the unicorn configuration file. +The `before_fork` Proc object will be called by the master process before forking each worker. +In our configuration file it kills the master process that belongs to the .oldbin PID. + +Sending the USR2 signal with an init.d script forks the unicorn master process and gives the former process an old pid. +The process with the old pid gets a QUIT signal from the before_fork code when the new master process starts a new worker process. +The old master and its workers are able to finish their jobs and end afterwards. + + +##unicorn configuration file in the application directory +can go to application directory e.g.: `/home/USER/opentox-ruby/APPLICATION/unicorn.rb` + +<script src="https://gist.github.com/4037704.js"> </script> + + +## init.d script to start|stop|restart|force-stop|upgrade the webservice +Script is `/etc/init.d/investigation` . + +<script src="https://gist.github.com/4037667.js"> </script> + + +## Embed it in a Debian System +* To make it work on system startup add the init.d script (start and stop) to the runlevels defined in the head of the script (Default-Start and Default-Stop) with `sudo update-rc.d APPLICATION defaults` . +* To enable logrotation for the errorlog file add `/etc/logrotate.d/investigation` to the logrotate.d directory with the content: + + /home/investigation/.opentox/log/unicorn-investigation.stderr.log { + copytruncate + daily + rotate 150 + missingok + create 640 investigation investigation + } +* To monitor the application with monit add the configuration file: `/etc/monit/conf.d/investigation` to make monit check if the pid-file exists. If not monit starts the service. + + check process investigation with pidfile /home/investigation/.opentox/pid/unicorn-investigation.pid + stop program = "/etc/init.d/investigation stop" + start program = "/etc/init.d/investigation start" |