added systemd unti files

This commit is contained in:
André Bauer 2017-09-16 17:48:42 +02:00
parent 437758673e
commit 7c24141cdf
5 changed files with 95 additions and 9 deletions

View file

@ -0,0 +1,24 @@
[Unit]
Description=Zammad railsserver
After=syslog.target
After=network.target
After=zammad.service
Requires=zammad.service
[Service]
Type=simple
User=zammad
Group=zammad
Restart=always
WorkingDirectory=/opt/zammad
Environment=RAILS_ENV=production
Environment=BUNDLE_BINARY=bundle
Environment=ZAMMAD_BIND_IP=127.0.0.1
Environment=ZAMMAD_RAILS_PORT=3000
ExecStart=/bin/bash -l -c "${BUNDLE_BINARY} exec script/rails server -b ${ZAMMAD_BIND_IP} -p ${ZAMMAD_RAILS_PORT}"
[Install]
WantedBy=zammad.service

View file

@ -0,0 +1,22 @@
[Unit]
Description=Zammad scheduler
After=syslog.target
After=network.target
After=zammad.service
Requires=zammad.service
[Service]
Type=simple
User=zammad
Group=zammad
Restart=always
WorkingDirectory=/opt/zammad
Environment=RAILS_ENV=production
Environment=BUNDLE_BINARY=bundle
ExecStart=/bin/bash -l -c "${BUNDLE_BINARY} exec script/scheduler.rb start -t"
[Install]
WantedBy=zammad.service

View file

@ -0,0 +1,24 @@
[Unit]
Description=Zammad websocket
After=syslog.target
After=network.target
After=zammad.service
Requires=zammad.service
[Service]
Type=simple
User=zammad
Group=zammad
Restart=always
WorkingDirectory=/opt/zammad
Environment=RAILS_ENV=production
Environment=BUNDLE_BINARY=bundle
Environment=ZAMMAD_BIND_IP=127.0.0.1
Environment=ZAMMAD_WEBSOCKET_PORT=6042
ExecStart=/bin/bash -l -c "${BUNDLE_BINARY} exec script/websocket-server.rb -b ${ZAMMAD_BIND_IP} -p ${ZAMMAD_WEBSOCKET_PORT} start"
[Install]
WantedBy=zammad.service

View file

@ -2,18 +2,17 @@
Description=Zammad
After=syslog.target
After=network.target
StopWhenUnneeded=true
Wants=zammad-rails.service
Wants=zammad-scheduler.service
Wants=zammad-websocket.service
[Service]
Type=simple
User=<zammad
User=zammad
Group=zammad
ExecStart=bash -l -c "RAILS_ENV=production bundle exec script/websocket-server.rb start -d -i tmp/pids/websocket.pid -p 6042 -b 127.0.0.1"
ExecStop=bash -l -c "RAILS_ENV=production bundle exec script/websocket-server.rb stop -d -i tmp/pids/websocket.pid -p 6042 -b 127.0.0.1"
# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300
Restart=always
ExecStart=/bin/sleep infinity
[Install]
WantedBy=multi-user.target
WantedBy=multi-user.target

17
contrib/systemd/zammad.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
#
# enable zammad systemd services
#
if [ "$(whoami)" != 'root' ]; then
echo "you need to be root to run this script!"
exit 1
fi
cp zammad.service zammad-rails.service zammad-scheduler.service zammad-websocket.service /etc/systemd/system
systemctl daemon-reload
systemctl enable zammad
systemctl start zammad