Commit 7583b5c
authored
Ensure agent exits if process receives SIGINT or SIGTERM signal (#100)
Ensure that the agent process exits if the process receives a `SIGINT`
or `SIGTERM` signal.
**Tests:**
- Validate process will exit if TTY is set:
- Created a new Ubuntu arm64 VM
- Built agent with `make docker-build`
- Ran agent in VM and sent a `Ctrl-C` signal
- Confirmed agent process exited
- Validate process will exit when run as daemon:
- Created a new Ubuntu arm64 VM
- Built agent with `make docker-build`
- Added a new `.service` file
- Reloaded systemd configuration with `systemctl daemon-reload`
- Enabled service with `systemctl enable postman-insights-agent.service`
- Confirmed successful daemon startup with `journalctl -fu
postman-insights-agent.service`
- Sent SIGINT signal with `kill -2 {process-id}`
- Confirmed agent process exited
**Logs:**
*Interactive (TTY is set) logs:*
```sh
dev@ubuntu-insights-agent:~$ sudo POSTMAN_API_KEY=$INSIGHTS_KEY ./postman-insights-agent apidump --project $PROJECT_ID
[INFO] Telemetry unavailable; no Amplitude key configured.
[INFO] This is caused by building from source rather than using an official build.
[INFO] Postman Insights Agent 0.0.0
[INFO] Created new trace on Postman Cloud: akita://Test Project:trace:aquamarine-mark-f6c0e9b5
[INFO] Failed to clear VmHWM. Memory usage telemetry will report the high-water mark as computed by /proc/self/status.
[INFO] Running learn mode on interfaces lo, enp0s5
[INFO] --filter flag is not set; capturing all network traffic to and from your services.
[INFO] Send SIGINT (Ctrl-C) to stop...
^C[INFO] Received interrupt, stopping trace collection...
[INFO] Trace collection stopped
[INFO] Captured 454 TCP packets total; 301 unparsed TCP segments. No TLS headers were found, so this may represent a network protocol that the agent does not know how to parse.
[ERROR] No HTTP calls captured! 🛑
```
*Systemd daemon logs:*
```sh
Mar 26 20:01:32 ubuntu-insights-agent systemd[1]: Started postman-insights-agent.service - Postman Insights Agent.
Mar 26 20:01:32 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] Telemetry unavailable; no Amplitude key configured.
Mar 26 20:01:32 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] This is caused by building from source rather than using an official build.
Mar 26 20:01:32 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] Postman Insights Agent 0.0.0
Mar 26 20:01:33 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] Created new trace on Postman Cloud: akita://Test Project:trace:tree-lady-44b4e9a1
Mar 26 20:01:33 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] Failed to clear VmHWM. Memory usage telemetry will report the high-water mark as computed by /proc/self/status.
Mar 26 20:01:33 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] Running learn mode on interfaces lo, enp0s5
Mar 26 20:01:33 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] --filter flag is not set; capturing all network traffic to and from your services.
Mar 26 20:01:33 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] Send SIGINT (Ctrl-C) to stop...
Mar 26 20:02:25 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] Received interrupt, stopping trace collection...
Mar 26 20:02:30 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] Trace collection stopped
Mar 26 20:02:30 ubuntu-insights-agent postman-insights-agent[5069]: [INFO] Captured 2 TLS handshake messages out of 6997 total TCP segments. This may mean you are trying to capture HTTPS traffic, which is currently unsupported.
Mar 26 20:02:30 ubuntu-insights-agent postman-insights-agent[5069]: [ERROR] No HTTP calls captured! 🛑
Mar 26 20:02:30 ubuntu-insights-agent systemd[1]: postman-insights-agent.service: Deactivated successfully.
Mar 26 20:02:30 ubuntu-insights-agent systemd[1]: postman-insights-agent.service: Consumed 1.703s CPU time, 48.1M memory peak, 0B memory swap peak.
```1 parent db27c08 commit 7583b5c
2 files changed
+21
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
857 | 859 | | |
858 | 860 | | |
859 | 861 | | |
| 862 | + | |
| 863 | + | |
860 | 864 | | |
861 | 865 | | |
862 | 866 | | |
| |||
927 | 931 | | |
928 | 932 | | |
929 | 933 | | |
930 | | - | |
931 | | - | |
| 934 | + | |
| 935 | + | |
932 | 936 | | |
933 | 937 | | |
934 | 938 | | |
| |||
991 | 995 | | |
992 | 996 | | |
993 | 997 | | |
994 | | - | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
995 | 1004 | | |
996 | 1005 | | |
997 | | - | |
998 | 1006 | | |
999 | 1007 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
95 | 96 | | |
96 | 97 | | |
97 | 98 | | |
98 | | - | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
106 | 110 | | |
107 | | - | |
| 111 | + | |
108 | 112 | | |
109 | 113 | | |
110 | 114 | | |
| |||
0 commit comments