Menu Close

Create the systemctl scripts

By default the is a “/usr/lib/systemd/system/polkadot.service” systemctl script which reads its defaults from “/etc/default/polkadot”. I find it handier to copy the scripts and put the appropriate command line config inside.

root@stakeworld:~# cp /usr/lib/systemd/system/polkadot.service /etc/systemd/system/kusama-stakeworld.service

Multiple instances

Theoretically it is possible to create multiple systemctl scripts and run multiple instances of the polkadot binary on the same system although this is not benificial for the polkadot ecosystem stability a demand higher resources on your server.

root@stakeworld:~# cp /etc/systemd/system/kusama-stakeworld.service /etc/systemd/system/kusama-stakeworld-01.service

Following my adapted systemctl script (/etc/systemd/system/kusama.service). As you can see i choose different ports to be able to use it alongside my polkadot validator. If you run more instances you need to adapt the ports and base directories alpongside the “Description” in the .service file.

  • –chain: kusam or polkadot (or westend)
  • –name: the name of the validator
  • –unsafe-pruning –pruning 1000: a pruned database is enough for a validator and saves precious ssd space
  • –validator: declare ourself a validator
  • –port 30334 –rpc-port 9934 –ws-port 9945: select alternative ports when using multiple instances
  • –prometheus-port 9621 needed for monitoring
  • –database rocksdb or paritydb to choose the database format
  • –base-path /home/polkadot/kusama-stakeworld-01: The base path allows for a different database location.
  • –telemetry-url ‘wss://telemetry.polkadot.io/submit/ 1’ , this is the default.
[Unit]
Description=Kusama Stakeworld
After=network.target
Documentation=https://github.com/paritytech/polkadot

[Service]
ExecStart=/usr/bin/polkadot --chain polkadot --name STAKEWORLD/01 --unsafe-pruning --pruning 1000 --validator --port 30321 --rpc-port 9921 --ws-port 9821 --prometheus-port 9621 --base-path /home/polkadot/polkadot-stakeworld-01 --database paritydb --telemetry-url 'wss://telemetry.polkadot.io/submit/ 1'
User=polkadot
Group=polkadot
Restart=always
RestartSec=120
CapabilityBoundingSet=
LockPersonality=true
NoNewPrivileges=true
PrivateDevices=true
PrivateMounts=true
PrivateTmp=true
PrivateUsers=true
ProtectClock=true
ProtectControlGroups=true
ProtectHostname=true
ProtectKernelModules=true
ProtectKernelTunables=true
ProtectSystem=strict
RemoveIPC=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_NETLINK AF_UNIX
RestrictNamespaces=true
RestrictSUIDSGID=true
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallFilter=~@clock @module @mount @reboot @swap @privileged
UMask=0027

[Install]
WantedBy=multi-user.target
sudo -u polkadot mkdir /home/polkadot/polkadot-stakeworld-01
systemctl daemon-reload
systemctl start polkadot-stakeworld-01.service
journalctl -u polkadot-stakeworld-01.service -f

If all went wel you can now see synchronisation starting in the logs and your node shows up in https://telemetry.polkadot.io/