Search This Blog

Showing posts with label Redis. Show all posts
Showing posts with label Redis. Show all posts

Thursday, May 3, 2018

Redmine 3.45 install Debian 9 stretch with SystemD

Please notice this is a quick and slim example only for non-multi user environment.

It fits my need very well.

Can hold up to 50 Clients at same time.

I am using SQLite as database because I love it.

apt-get install curl dirmngr
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

source /etc/profile.d/rvm.sh
rvm requirements

rvm install 2.4

rvm use 2.4 --default
ruby -v

echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

gem install bundler --no-ri --no-rdoc
gem install sqlite3 --no-ri --no-rdoc


cd /var/www/redmine/
cp config/database.yml.example config/database.yml

My config/database.yml:
production:
  adapter: sqlite3
  database: db/redmine.sqlite3

Start install:
bundle install --without development test rmagick
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data

Testing it out:
bundle exec rails server webrick -e production -b 192.168.1.33 -p 80

Run as systemd service: add file

/etc/systemd/system/redmine.service
[Unit]
Description=Redmine server
After=syslog.target
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/bin/bash -c 'source /etc/profile.d/rvm.sh && cd /var/www/redmine && bundle exec rails server webrick -e production -b 192.168.1.33 -p 80'

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

To start it:
systemctl enable redmine.service
systemctl start redmine.service

What to improve:

  1. I run it as [root] user it may not super safe, but this is just for internal use.

  2. Redmine Log rotation, please reference my old post: Redmine Log rotation

Monday, May 16, 2016

Debian Jessie Keepalived simple Redis Cluster

Even though keepalived under Debian Jessi give samples of check local service with killall in /usr/share/doc/keepalived/samples/keepalived.conf.vrrp.localcheck

vrrp_script chk_haproxy {
script "killall -0 haproxy" # cheaper than pidof
interval 2 # check every 2 seconds
}


But Jessie only have SystemD. [killall] has been remove with SystemV.
You can still use killall5 which is the SystemV killall command.

But killall5 simulates the killall command of SysV UNIX; it sends the given signal to all processes owned by the calling UID. When does it root, it can do very bad things. BE VERY CAREFUL with the killall command on!


# cat /etc/keepalived/keepalived.conf

vrrp_script chk_redis {
script "pidof redis-server" # pidof inside of killall, just to be safe.
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 59
priority 100 # 101 on master, 100 on backup
virtual_ipaddress {
192.168.1.10
}
track_script {
chk_redis
}
}


In my opinion pidof is safer than killall or killall5.