# PYRE / Prometheus Protocol — systemd unit to resurrect PM2 on boot. # # INERT until apps are deployed AND `pm2 save` has been run at least once: # `pm2 resurrect` only restores processes from the saved dump # (~/.pm2/dump.pm2). Without that dump it starts nothing. # # Install (run as a privileged user, once): # sudo cp /home/pyre/pyre/infra/systemd/pm2-pyre.service /etc/systemd/system/pm2-pyre.service # sudo systemctl daemon-reload # sudo systemctl enable pm2-pyre # # Then, after the apps are built and started: # pm2 start /home/pyre/pyre/ecosystem.config.cjs # pm2 save # <-- REQUIRED: writes the dump that resurrect reads # # This unit runs PM2 as the unprivileged `pyre` user (no root daemon). [Unit] Description=PM2 process manager for PYRE (user pyre) Documentation=https://pm2.keymetrics.io/ After=network-online.target postgresql.service redis-server.service Wants=network-online.target [Service] Type=forking User=pyre LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity Environment=PATH=/home/pyre/.local/share/pnpm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin Environment=PM2_HOME=/home/pyre/.pm2 PIDFile=/home/pyre/.pm2/pm2.pid Restart=on-failure ExecStart=/home/pyre/.local/share/pnpm/bin/pm2 resurrect ExecReload=/home/pyre/.local/share/pnpm/bin/pm2 reload all ExecStop=/home/pyre/.local/share/pnpm/bin/pm2 kill [Install] WantedBy=multi-user.target