To set up the NICOS server on your local machine, follow these steps.
Install the necessary Python packages (it's recommended to use a virtual environment):
pip install -r requirements.txtCreate a directory for storing NICOS data:
mkdir /opt/nicos-dataNote: This may require sudo rights. Ensure the directory has the correct ownership.
Link the configuration file for your chosen instrument:
ln -s nicos_ess/<instrument>/nicos.conf .A good starting instrument is ymir, which is a test instrument.
Start the NICOS cache server:
./bin/nicos-cacheTo configure what cache database to use, see section Configure Cache Database.
In a separate terminal, start the NICOS poller:
./bin/nicos-pollerIf required, start the NICOS collector in another terminal:
./bin/nicos-collectorFinally, in another terminal, start the NICOS daemon:
./bin/nicos-daemonInstall the necessary packages for the NICOS GUI:
pip install -r requirements-gui.txtStart the NICOS client with your selected instrument's configuration:
./bin/nicos-gui -c nicos_ess/<instrument>/guiconfig.pyIf you prefer QT6, use the following command (not required on macOS with silicon architecture):
NICOS_QT=6 ./bin/nicos-gui -c nicos_ess/<instrument>/guiconfig.pyNICOS supports different cache databases. You can use MemoryCacheDatabase, FlatfileCacheDatabase, or RedisCacheDatabase. For local development, MemoryCacheDatabase or FlatfileCacheDatabase are easiest to set up.
Edit the cache.py setup file to choose your cache database:
vim nicos_ess/<instrument>/setups/special/cache.pyNo changes needed if you are using the default MemoryCacheDatabase:
DB=device(
"nicos.services.cache.server.MemoryCacheDatabase",
loglevel="info",
)To use FlatfileCacheDatabase, update the setup file as follows:
DB=device(
"nicos.services.cache.server.FlatfileCacheDatabase",
storepath="/opt/nicos-data/cache",
loglevel="info",
)For Redis-based caching, RedisCacheDatabase, configure as follows:
DB=device(
"nicos.services.cache.server.RedisCacheDatabase",
loglevel="info",
)In the case of RedisCacheDatabase, you need to set up Redis and RedisTimeSeries. See section Redis Setup for instructions.
To set up your environment for development, install the additional required packages:
pip install -r requirements-dev.txtInstall the pre-commit hook to ensure code quality:
pre-commit installThis section guides you through installing Redis, an in-memory data store, and RedisTimeSeries, a module for time-series data processing. The RedisTimeSeries module is mandatory.
The instructions are for Linux systems (tested on ubuntu 22.04 and CentOS 7). For other operating systems, refer to the Redis and RedisTimeSeries documentation.
Download and extract the Redis package:
wget http://download.redis.io/releases/redis-6.2.14.tar.gz
tar xzf redis-6.2.14.tar.gz
cd redis-6.2.14Compile the Redis source code:
makeOptional but recommended: Run tests to ensure Redis is functioning correctly.
make testInstall Redis on your system:
sudo make installCreate a directory for the Redis configuration file:
sudo mkdir /etc/redisCopy the default configuration file:
sudo cp redis.conf /etc/redis/redis.confOpen the configuration file to apply necessary settings:
sudo vim /etc/redis/redis.confIMPORTANT: Ensure Redis is bound to localhost for security:
bind 127.0.0.1 ::1
protected-mode yes
supervised systemd
dir /var/lib/redisCreate a service file to manage Redis with systemd:
sudo vim /etc/systemd/system/redis.servicePaste the following configuration, replacing nicos with your username (on the nicosservers, it's nicos):
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=nicos
Group=nicos
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
[Install]
WantedBy=multi-user.targetCreate and set permissions for the Redis data directory:
sudo mkdir /var/lib/redis
sudo chown nicos:nicos /var/lib/redis
sudo chmod 770 /var/lib/redisEnable and start the Redis service:
sudo systemctl enable redis
sudo systemctl start redisOptionally, check the status to ensure Redis is running smoothly:
sudo systemctl status redisFind the Redis CLI tool:
sudo find / -name redis-cliAdd Redis binaries to your system PATH:
vim ~/.bashrc
export PATH=$PATH:/usr/local/bin
source ~/.bashrcTest that Redis is installed and running correctly:
redis-cli pingClone the RedisTimeSeries repository:
git clone --recursive https://github.com/RedisTimeSeries/RedisTimeSeries.git -b v1.8.10
cd RedisTimeSeriesSet up the environment and build the module:
./sbin/setup
bash -l
makeCopy the RedisTimeSeries module to the appropriate directory:
cp RedisTimeSeries/bin/linux-x64-release/redistimeseries.so /etc/redis/redistimeseries.soTo load the RedisTimeSeries module, add this line to redis.conf:
loadmodule /etc/redis/redistimeseries.soRestart Redis to apply changes:
sudo systemctl restart redisCheck that the RedisTimeSeries module is loaded correctly:
redis-cli MODULE LIST