From fc40f4a30a104215bcb1118e38711fd7314fb005 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 27 Apr 2024 00:36:17 +0300 Subject: [PATCH] add systemd example --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 5012d06..f933401 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,32 @@ php src/nex.php host=127.0.0.1 port=1900 path=/target/dir * `{port}` - peer port * `{path}` - path requested * `{goal}` - goal destination returned + +### Autostart + +Launch server as the `systemd` service + +Following example mean you have `next` server installed into home directory of `next` user (`useradd -m next`) + +1. `sudo nano /etc/systemd/system/next.service` - create new service: + +``` next.service +[Unit] +After=network.target + +[Service] +Type=simple +User=next +Group=next +ExecStart=/usr/bin/php /home/next/next/src/nex.php path=/home/next/public +StandardOutput=file:/home/next/debug.log +StandardError=file:/home/next/error.log +Restart=on-failure + +[Install] +WantedBy=multi-user.target +``` + +2. `sudo systemctl daemon-reload` - reload systemd configuration +3. `sudo systemctl enable next` - enable `next` service on system startup +4. `sudo systemctl start next` - start `next` server