Manger Server On Linux With Systemd

Linux Server - Tweaking Things With Systemd

Here are some notes about my recent tweaks and mods to my Linux server which is running my installation of Manager. Currently, I am using Ubuntu 16.04 server, but these notes should be good for anyone with a version of Linux that uses Systemd for it’s init system.

Background:-
Many Linux distributions these days are now using systemd for their init system.
Restarting the server every time it gets an updated version of Manager can be a bit of a chore and inconvenience, particularly when the server is providing a cocktail of other services to a number of other clients.
Systemd allows us to stop and start services more or less on demand without having to do a full re-start of the entire machine.

Assumptions & Prerequisites
A server that is running a version of Linux with the Systemd init system
You have followed the Linux installation tutorial on the Manager.io website and you have a working installing of Manager Server that starts automatically when powered-up.
You are fully backed-up.
If you are not comfortable messing about with the heart of a live production system, then this is might not be for you - - - maybe instead you should try it out and practice in a virtual machine before committing things to your live production installation.
I have chosen to call my service “managerstart”. This is just for my convenience as it can in truth be called anything you want it to be, the only requirement being, that once you have stettled on a name, then stick to it throughout.

Edit your rc.local

sudo nano /etc/rc.local

prefix your autostart entry for manager with a “#” - - make it look like this:-

# /usr/bin/mono /usr/share/manager-server/ManagerServer.exe -port 8080 >>/dev/null 2>&1 &

and save the file

Create a script

sudo nano /usr/bin/managerstart

add the following entry, and save.

#!/bin/sh
mono /usr/share/manager-server/ManagerServer.exe

Make the file executable

sudo chmod +x /usr/bin/managerstart

Create a Systemd .service file

sudo nano /etc/systemd/system/managerstart.service

add the following entry, and save

[Unit]
Description=Power-on and start Manager Accounts

[Service]
Type=oneshot
ExecStart=/usr/bin/managerstart

[Install]
WantedBy=multi-user.target

To Enable The Service:-

sudo systemctl enable managerstart.service

Manager will now start automatically after rebooting the machine.

In the future, after updating to the latest version of Manager, you will not need to restart your server, you can just issue a command:-

sudo systemctl restart managerstart

More Notes about Systemd and restarting things:

Restarting and Reloading Using Systemctl

To restart a running service, you can use the restart command:
sudo systemctl restart managerstart

It is also possible to reload configuration files (without restarting), you can issue the reload command to initiate that process:
sudo systemctl reload managerstart

If you are unsure whether the your installation has the functionality to reload its configuration, you can issue the reload-or-restart command. This will reload the configuration in-place if available. Otherwise, it will restart the service so the new configuration is picked up:
sudo systemctl reload-or-restart managerstart

Checking the Status of The Manger Service
To check the status of the manager service on your system, you can use the status command:
systemctl status managerstart

Other Systemd / Systemctl stuff

There are also methods for checking for specific states. For instance, to check to see if manager is currently active (running), you can use is-active :
systemctl is-active managerstart
This will return the current state, which is usually active or inactive. The exit code will be “0” if it is active.

To see if manager is enabled, you can use the is-enabled:
systemctl is-enabled managerstart
This will output whether the service is enabled or disabled and will again set the exit code to “0” or “1”

A third check is whether manager is in a failed state. This indicates that there was a problem starting
systemctl is-failed managerstart
This will return active if it is running properly or failed if an error occurred. If manager was intentionally stopped, it may return unknown or inactive. An exit status of “0” indicates that a failure occurred and an exit status of “1” indicates any other status.

1 Like

Nice!

I did something similar a while ago, You might be interested?

Some things you could pinch:

  • runs under a standard user account account instead of root.
  • launch script respawns manager if it terminates unexpectedly

I’ve also got a reverse proxy in front of manager so it runs over https, can post config if you like.

1 Like

@fsr - that looks really nice - many thanks for the links

I would be interested in learning about the reverse proxy

uploaded an sample to here:
https://github.com/frasersdev/manager-server/raw/master/etc/apache2/sites-available/https.manager.conf

to use do the following

  • Install apache2
  • enable mod_proxy and mod_rewrite
  • put the config file into /etc/apache2/sites-available
  • edit to suit (server name, admin email, manager-server host / port, certs, log file locations etc)
  • disable the default sites and just enable this one
  • restart apache and enjoy the encrypted web

only issue I’ve found is if you browse the api tree the urls don’t get re-written (might be the rev-proxy can’t see them - e.g. generated by javascript or something). no biggie though.

have fun!