Jump to content

How monitor mysql and Ruby server


maykapl

Recommended Posts

can anyone show me how can i connect Pulseway to monitors mysql, and Ruby App ?

mysql is on /usr/sbin/mysqld -> 
<Service Name="mysql" DisplayName="MySql" Path="" StartParameters="" CanBeStopped="false" Enabled="true"/>

but what about  setting ' IsDaemon="true" DaemonType="UPSTART" ' ? SYSV, UPSTARTD and SYSTEMD ?

I have same problem with puma from rails server, its on  (unix:///home/test/prod.sock)

 

 

Link to comment
Share on other sites

  • 3 weeks later...

For other user, It should be in FAQ ;)

Works on Ubuntu 12/14

1. Create 2 files in /etc/init/puma.conf and /etc/init/puma-manager.conf

 

# /etc/init/puma.conf - Puma config

# This example config should work with Ubuntu 12.04+.  It
# allows you to manage multiple Puma instances with
# Upstart, Ubuntu's native service management tool.
#
# See puma-manager.conf for how to manage all Puma instances at once.
#
# Save this config as /etc/init/puma.conf then manage puma with:
#   sudo start puma app=PATH_TO_APP
#   sudo stop puma app=PATH_TO_APP
#   sudo status puma app=PATH_TO_APP
#
# or use the service command:
#   sudo service puma {start,stop,restart,status}
#

description "Puma Background Worker"

# no "start on", we don't want to automatically start
stop on (stopping puma-manager or runlevel [06])

# change apps to match your deployment user if you want to use this as a less privileged user (recommended!)
setuid YOUR_USER_NAME
setgid YOUR_USER_NAME

respawn
respawn limit 3 30

instance ${app}
script
# this script runs in /bin/sh by default
# respawn as bash so we can source in rbenv/rvm
# quoted heredoc to tell /bin/sh not to interpret
# variables

# source ENV variables manually as Upstart doesn't, eg:
#. /etc/environment

exec /bin/bash <<'EOT'
  # set HOME to the setuid user's home, there doesn't seem to be a better, portable way
  export HOME="$(eval echo ~$(id -un))"

  if [ -d "/usr/local/rbenv/bin" ]; then
    export PATH="/usr/local/rbenv/bin:/usr/local/rbenv/shims:$PATH"
  elif [ -d "$HOME/.rbenv/bin" ]; then
    export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
  elif [ -f  /etc/profile.d/rvm.sh ]; then
    source /etc/profile.d/rvm.sh
  elif [ -f /usr/local/rvm/scripts/rvm ]; then
    source /etc/profile.d/rvm.sh
  elif [ -f "$HOME/.rvm/scripts/rvm" ]; then
    source "$HOME/.rvm/scripts/rvm"
  elif [ -f /usr/local/share/chruby/chruby.sh ]; then
    source /usr/local/share/chruby/chruby.sh
    if [ -f /usr/local/share/chruby/auto.sh ]; then
      source /usr/local/share/chruby/auto.sh
    fi
    # if you aren't using auto, set your version here
    # chruby 2.0.0
  fi

  cd $app
  logger -t puma "Starting server: $app"

  exec bundle exec puma -C config/puma.rb
EOT
end script

 

# /etc/init/puma-manager.conf - manage a set of Pumas

# This example config should work with Ubuntu 12.04+.  It
# allows you to manage multiple Puma instances with
# Upstart, Ubuntu's native service management tool.
#
# See puma.conf for how to manage a single Puma instance.
#
# Use "stop puma-manager" to stop all Puma instances.
# Use "start puma-manager" to start all instances.
# Use "restart puma-manager" to restart all instances.
# Crazy, right?
#

description "Manages the set of puma processes"

# This starts upon bootup and stops on shutdown
start on runlevel [2345]
stop on runlevel [06]

# Set this to the number of Puma processes you want
# to run on this machine
env PUMA_CONF="/etc/puma.conf"

pre-start script
    app='/var/www/app' # Destination folder with your app
    logger -t "puma-manager" "Starting $app"
    start puma app=$app
end script

2. Create in Your rails app file config/puma.rb

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 1)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection
end

Of course port and env you can change if it need.

3. Add in pulseway file (/etc/pulseway/config.xml) in <MonitoredServices>

<Service Name="puma-manager" DisplayName="Puma Manager" IsDaemon="true" DaemonType="UPSTART" Path="" StartParameters="" CanBeStopped="true" Enabled="true"/>

4. Restart pulseway ( sudo /etc/init.d/pulseway restart )

5. Start your app from pulseway or from console (sudo start puma-manager)

If everything is ok in Services will be "Puma manager" with green sign, if not check '/var/log/upstart/your_app_name.log'

 

Link to comment
Share on other sites

  • Administrators

Hi,

Mysql daemon status output doesn't respect the linux service standards hence why we can't monitor it as this is not yet supported. We have it on our Roadmap however there is no way to provide an ETA at this stage I've afraid.

-Paul

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...