forked from M-Labs/nix-servo
Start linien-server as a service in boot stage
This commit is contained in:
parent
d6169c87e1
commit
a6665d0c06
15
README.md
15
README.md
@ -16,6 +16,15 @@
|
|||||||
- MODE: ON
|
- MODE: ON
|
||||||
2. Install the SD Card, power up the board via the power jack or PoE and plug in the RJ45 Ethernet cable.
|
2. Install the SD Card, power up the board via the power jack or PoE and plug in the RJ45 Ethernet cable.
|
||||||
3. Wait for all the front panel LEDs except the termination status LEDs to turn off. It can take a minutes or two for first boot. If it does not boot up, try to flash the SD Card again.
|
3. Wait for all the front panel LEDs except the termination status LEDs to turn off. It can take a minutes or two for first boot. If it does not boot up, try to flash the SD Card again.
|
||||||
4. Run `ssh <fast servo ip address> -p 3030` to ssh into fast-servo and run `linien-server run` to start the linien server.
|
4. By default, linien-server starts up automatically. In case linien-server crashes, it will restart itself. Logs are stored in `/root/linien-server-log`. Here are some commands to interact with the linien-server service once you `ssh <fast servo ip address> -p 3030` into fast-servo.
|
||||||
5. In the dev shell, run `linien` to launch the GUI. Add new device. Username is `root` and it does not take any password to log in. You leave the password field with any text.
|
|
||||||
6. Select the newly added device and click connect in the GUI to connect and start the GUI.
|
| Description | Command |
|
||||||
|
|------------------------------------------------------|-----------------------------------------|
|
||||||
|
| Start the linien-server service | `linien-server start` |
|
||||||
|
| Stop the linien-server service | `linien-server stop` |
|
||||||
|
| Check if the linien-server service is running | `linien-server status` |
|
||||||
|
| Set the linien-server service to start at bootup | `linien-server enable` |
|
||||||
|
| Set the linien-server service not to start at bootup | `linien-server disable` |
|
||||||
|
|
||||||
|
4. In the dev shell, run `linien` to launch the GUI. Add new device. Username is `root` and it does not take any password to log in. You leave the password field with any text.
|
||||||
|
5. Select the newly added device and click connect in the GUI to connect and start the GUI.
|
||||||
|
73
fast-servo/linien-server-cli.patch
Normal file
73
fast-servo/linien-server-cli.patch
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
diff --git a/linien-client/linien_client/deploy.py b/linien-client/linien_client/deploy.py
|
||||||
|
index 7355cc3..876f1ec 100644
|
||||||
|
--- a/linien-client/linien_client/deploy.py
|
||||||
|
+++ b/linien-client/linien_client/deploy.py
|
||||||
|
@@ -83,14 +83,14 @@ def start_remote_server(
|
||||||
|
if (local_version != remote_version) and not ("dev" in local_version):
|
||||||
|
raise InvalidServerVersionException(local_version, remote_version)
|
||||||
|
|
||||||
|
- logger.debug("Sending credentials")
|
||||||
|
- conn.run(
|
||||||
|
- 'python3 -c "from linien_common.communication import write_hash_to_file;'
|
||||||
|
- f"write_hash_to_file('{hash_username_and_password(device.username, device.password)}')\"", # noqa E501
|
||||||
|
- out_stream=out_stream,
|
||||||
|
- err_stream=out_stream,
|
||||||
|
- warn=True,
|
||||||
|
- )
|
||||||
|
+ # logger.debug("Sending credentials")
|
||||||
|
+ # conn.run(
|
||||||
|
+ # 'python3 -c "from linien_common.communication import write_hash_to_file;'
|
||||||
|
+ # f"write_hash_to_file('{hash_username_and_password(device.username, device.password)}')\"", # noqa E501
|
||||||
|
+ # out_stream=out_stream,
|
||||||
|
+ # err_stream=out_stream,
|
||||||
|
+ # warn=True,
|
||||||
|
+ # )
|
||||||
|
|
||||||
|
logger.debug("Starting server")
|
||||||
|
conn.run(
|
||||||
|
diff --git a/linien-server/linien_server/cli.py b/linien-server/linien_server/cli.py
|
||||||
|
index 7781c74..827d04f 100644
|
||||||
|
--- a/linien-server/linien_server/cli.py
|
||||||
|
+++ b/linien-server/linien_server/cli.py
|
||||||
|
@@ -44,20 +44,19 @@ class LinienServerCLI:
|
||||||
|
|
||||||
|
def start(self) -> None:
|
||||||
|
"""Start the Linien server as a systemd service."""
|
||||||
|
- copy_systemd_service_file()
|
||||||
|
logger.info("Starting Linien server")
|
||||||
|
- subprocess.run(["systemctl", "start", "linien-server.service"])
|
||||||
|
+ subprocess.run(["sv", "up", "/etc/service/linien-server"])
|
||||||
|
logger.info("Started Linien server")
|
||||||
|
|
||||||
|
def stop(self) -> None:
|
||||||
|
"""Stop the Linien server running as a systemd service."""
|
||||||
|
logger.info("Stopping Linien server")
|
||||||
|
- subprocess.run(["systemctl", "stop", "linien-server.service"])
|
||||||
|
+ subprocess.run(["sv", "down", "/etc/service/linien-server"])
|
||||||
|
logger.info("Stopped Linien server")
|
||||||
|
|
||||||
|
def status(self) -> None:
|
||||||
|
"""Check the status of the Linien server."""
|
||||||
|
- subprocess.run(["journalctl", "-u", "linien-server.service"])
|
||||||
|
+ subprocess.run(["sv", "status", "/etc/service/linien-server"])
|
||||||
|
|
||||||
|
def run(self, fake: bool = False, host: Optional[str] = None) -> None:
|
||||||
|
"""
|
||||||
|
@@ -89,15 +88,14 @@ class LinienServerCLI:
|
||||||
|
|
||||||
|
def enable(self) -> None:
|
||||||
|
"""Enable the Linien server to start on boot."""
|
||||||
|
- copy_systemd_service_file()
|
||||||
|
logger.info("Enabling Linien server")
|
||||||
|
- subprocess.run(["systemctl", "enable", "linien-server.service"])
|
||||||
|
+ subprocess.run(["rm", "/etc/service/linien-server/down"])
|
||||||
|
logger.info("Enabled Linien server")
|
||||||
|
|
||||||
|
def disable(self) -> None:
|
||||||
|
"""Disable the Linien server from starting on boot."""
|
||||||
|
logger.info("Disabling Linien server")
|
||||||
|
- subprocess.run(["systemctl", "disable", "linien-server.service"])
|
||||||
|
+ subprocess.run(["touch", "/etc/service/linien-server/down"])
|
||||||
|
logger.info("Disabled Linien server")
|
||||||
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
|||||||
./fast-servo/linien-gui-fast-servo-hardware-specific.patch
|
./fast-servo/linien-gui-fast-servo-hardware-specific.patch
|
||||||
./fast-servo/linien-client-ssh-port-change.patch
|
./fast-servo/linien-client-ssh-port-change.patch
|
||||||
./fast-servo/linien-server-fast-servo.patch
|
./fast-servo/linien-server-fast-servo.patch
|
||||||
|
./fast-servo/linien-server-cli.patch
|
||||||
./fast-servo/linien-gateware-fast-servo.patch
|
./fast-servo/linien-gateware-fast-servo.patch
|
||||||
./fast-servo/linien-gateware-autolock-pipeline.patch
|
./fast-servo/linien-gateware-autolock-pipeline.patch
|
||||||
./fast-servo/linien-module-iir-coeff-width-set-to-18bit.patch
|
./fast-servo/linien-module-iir-coeff-width-set-to-18bit.patch
|
||||||
@ -54,6 +55,7 @@
|
|||||||
./not-os-patches/pr-30.patch
|
./not-os-patches/pr-30.patch
|
||||||
./not-os-patches/pr-31.patch
|
./not-os-patches/pr-31.patch
|
||||||
./not-os-patches/pr-33.patch
|
./not-os-patches/pr-33.patch
|
||||||
|
./not-os-patches/pr-34.patch
|
||||||
./not-os-patches/iproute2.patch
|
./not-os-patches/iproute2.patch
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@ -350,6 +352,7 @@
|
|||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out $out/nix-support
|
mkdir -p $out $out/nix-support
|
||||||
cp gateware/build/top.bit $out
|
cp gateware/build/top.bit $out
|
||||||
|
cp gateware/build $out -r
|
||||||
cp linien-server/linien_server/gateware.bin $out
|
cp linien-server/linien_server/gateware.bin $out
|
||||||
cp linien-server/linien_server/csrmap.py $out
|
cp linien-server/linien_server/csrmap.py $out
|
||||||
echo file binary-dist $out/top.bit >> $out/nix-support/hydra-build-products
|
echo file binary-dist $out/top.bit >> $out/nix-support/hydra-build-products
|
||||||
@ -651,6 +654,9 @@
|
|||||||
in rec {
|
in rec {
|
||||||
devShell.x86_64-linux = pkgs.mkShell {
|
devShell.x86_64-linux = pkgs.mkShell {
|
||||||
name = "nix-servo-dev_shell";
|
name = "nix-servo-dev_shell";
|
||||||
|
packages = [
|
||||||
|
vivado
|
||||||
|
];
|
||||||
buildInputs = with pkgs.python3Packages; [
|
buildInputs = with pkgs.python3Packages; [
|
||||||
matplotlib
|
matplotlib
|
||||||
] ++ [ linien-common linien-client linien-gui ];
|
] ++ [ linien-common linien-client linien-gui ];
|
||||||
|
20
not-os-patches/pr-34.patch
Normal file
20
not-os-patches/pr-34.patch
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
diff --git a/zynq_image.nix b/zynq_image.nix
|
||||||
|
index 069fe89..979b760 100644
|
||||||
|
--- a/zynq_image.nix
|
||||||
|
+++ b/zynq_image.nix
|
||||||
|
@@ -51,6 +51,15 @@ in {
|
||||||
|
hostname ${config.networking.hostName}
|
||||||
|
exec setsid agetty ttyPS0 115200
|
||||||
|
'';
|
||||||
|
+ "service/linien-server/run".source = pkgs.writeShellScript "linien-server" ''
|
||||||
|
+ exec 2>&1
|
||||||
|
+ exec setsid linien-server run
|
||||||
|
+ '';
|
||||||
|
+ "service/linien-server/log/run".source = pkgs.writeShellScript "linien-server-logger" ''
|
||||||
|
+ exec 2>&1
|
||||||
|
+ mkdir -p /root/linien-server-log
|
||||||
|
+ exec svlogd -tt /root/linien-server-log
|
||||||
|
+ '';
|
||||||
|
"pam.d/other".text = ''
|
||||||
|
auth sufficient pam_permit.so
|
||||||
|
account required pam_permit.so
|
Loading…
Reference in New Issue
Block a user