| 12 Nov 2023 |
peter-lustig | but i execute the command PORT=5173 node . and if I test that locally everything just works | 13:11:59 |
peter-lustig | Here is my current systemd service:
systemd.services.myservice = {
wantedBy = ["multi-user.target"];
after = ["network-online.target"];
serviceConfig = {
Type = "simple";
ExecStart = "PORT=5173 ${pkgs.nodejs_20}/bin/node .";
WorkingDirectory = inputs.myservice.packages.${pkgs.system}.default;
Restart = "always";
};
};
| 13:17:00 |
Cobalt | Okay, have you tried going to the workingdirectory and executing node there? | 13:19:10 |
Lily Foster | POST=5173 is not a command | 13:19:20 |
Lily Foster | If you are trying to set an environment variable, set Environment = "PORT=5173 | 13:19:31 |
Lily Foster | * If you are trying to set an environment variable, set Environment = "PORT=5173" | 13:19:33 |
Lily Foster | * PORT=5173 is not a command | 13:19:51 |
Lily Foster | systemd doesn't run this stuff through bash | 13:20:00 |
peter-lustig | In reply to @lily:lily.flowers
PORT=5173 is not a command it is just a command line
from the docs:
PORT, HOST and SOCKET_PATHpermalink By default, the server will accept connections on 0.0.0.0 using port 3000. These can be customised with the PORT and HOST environment variables:
HOST=127.0.0.1 PORT=4000 node build Alternatively, the server can be configured to accept connections on a specified socket path. When this is done using the SOCKET_PATH environment variable, the HOST and PORT environment variables will be disregarded.
SOCKET_PATH=/tmp/socket node build
| 13:20:16 |
peter-lustig | In reply to @lily:lily.flowers
PORT=5173 is not a command * it is just a command line argument
from the docs:
PORT, HOST and SOCKET_PATHpermalink By default, the server will accept connections on 0.0.0.0 using port 3000. These can be customised with the PORT and HOST environment variables:
HOST=127.0.0.1 PORT=4000 node build Alternatively, the server can be configured to accept connections on a specified socket path. When this is done using the SOCKET_PATH environment variable, the HOST and PORT environment variables will be disregarded.
SOCKET_PATH=/tmp/socket node build
| 13:20:21 |
Lily Foster | It's a bash-ism, not a command line argument | 13:20:41 |
peter-lustig | okay, I will try the environment | 13:20:51 |
Lily Foster | If you are intending it to be an environment variable like bash does, you need to set it as an environment variable | 13:20:55 |
Lily Foster | (apologies if that sounded accusative. i only got up a bit ago and i guess am typing a bit short this morning) | 13:21:55 |
peter-lustig | ok the systemd service still fails | 13:22:12 |
peter-lustig | so seems like that was not the issue | 13:22:16 |
Lily Foster | it was 100% still an issue | 13:22:28 |
Lily Foster | even if there are other ones | 13:22:33 |
Cobalt | It may be helpful if you share the logs | 13:22:35 |
Cobalt | Or some kind of MRE | 13:23:16 |
peter-lustig | The unit myapp.service has entered the 'failed' state with result 'exit-code'.
Nov 12 14:21:52 server systemd[1]: Failed to start My application
░░ Subject: A start job for unit myapp.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit myapp.service has finished with a failure.
░░
░░ The job identifier is 1062533 and the job result is failed.
| 13:23:47 |
peter-lustig | does not help much | 13:23:50 |
peter-lustig | it is not specific | 13:23:55 |
Lily Foster | In reply to @peter-lustig:matrix.org
Here is my current systemd service:
systemd.services.myservice = {
wantedBy = ["multi-user.target"];
after = ["network-online.target"];
serviceConfig = {
Type = "simple";
ExecStart = "PORT=5173 ${pkgs.nodejs_20}/bin/node .";
WorkingDirectory = inputs.myservice.packages.${pkgs.system}.default;
Restart = "always";
};
};
(also you probably want that to be wants = [ "network-online.target"] instead of after, since the former sets up an explicitly dependency but after only does ordering. it works for now, but we're going to be making multi-user.target no longer depend on network-online.target at some point) | 13:24:21 |
szucsitg | In reply to @lily:lily.flowers can you ping me in like 5 hours? i'm running an event at the moment, but can help later Maybe now? | 13:25:35 |
Lily Foster | In reply to @szucsitg:matrix.org Maybe now? yeah sure! apologies for forgetting yesterday (was a busy day) | 13:25:52 |
peter-lustig | In reply to @peter-lustig:matrix.org
The unit myapp.service has entered the 'failed' state with result 'exit-code'.
Nov 12 14:21:52 server systemd[1]: Failed to start My application
░░ Subject: A start job for unit myapp.service has failed
░░ Defined-By: systemd
░░ Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
░░
░░ A start job for unit myapp.service has finished with a failure.
░░
░░ The job identifier is 1062533 and the job result is failed.
as you can see it does not give me any info Cobalt | 13:25:57 |
Lily Foster | can you share your updated service definition? | 13:26:46 |
Lily Foster | that usually means systemd couldn't exec the command at all | 13:27:04 |
peter-lustig | systemd.services.myapp = {
description = "My application";
wantedBy = ["multi-user.target"];
wants = ["network-online.target"];
serviceConfig = {
Type = "simple";
Environment = "PORT=5173";
ExecStart = "${pkgs.nodejs_20}/bin/node .";
WorkingDirectory = inputs.myapp.packages.${pkgs.system}.default;
Restart = "always";
};
};
| 13:27:43 |