Logo Decentralized Social Network

Running

The JAR file is executable and contains Tomcat in it. Just run it with java:

$ SPRING_APPLICATION_JSON={"spring.profiles.active":"prod"} java -jar ./moera-node-0.17.0.jar

The value of spring.profiles.active setting (that is set above through SPRING_APPLICATION_JSON environment variable) should correspond to the name of your configuration file. If spring.profiles.active is set to prod, the configuration file should be named application-prod.yml.

After moera-node starts, the Moera node will be available on the port you have set in the configuration file.

Adding to systemd

You need to write a script to start moera-node automatically as a daemon when your server starts. If you have a systemd-based Linux distribution, the correct way would be to create a unit file and add it to systemd.

For example, create the following moera-node.service file:

[Unit]
Description=Moera server
After=syslog.target

[Service]
User=moeranode
Group=moeranode
ProtectSystem=full
ProtectHome=true
WorkingDirectory=/srv/moera-node
Environment=LANG=en_US.UTF-8 \
            'SPRING_APPLICATION_JSON={"spring.profiles.active":"prod"}' \
            JAVA_OPTS="-Xmx2G -XX:+UseG1GC -XX:+UseStringDeduplication"
ExecStart=/usr/bin/java -jar /srv/moera-node/moera-node-0.17.0.jar
SuccessExitStatus=143
StandardOutput=syslog
StandardError=inherit
SyslogIdentifier=moera-node

[Install]
WantedBy=multi-user.target

User= and Group= define the user and the group that will be used by the moera-node process. Remember to create the user and the group in your system.

The WAR file is located in /srv/moera-node directory in the example above. If the path on your server is different, put the correct path in WorkingDirectory= and ExecStart=.

You can set any JRE options you want in JAVA_OPTS environment variable. Explaining them is out of scope of this Guide.

To add the unit file to systemd, run

# systemctl enable ./moera-node.service

And then start the daemon:

# systemctl start moera-node