File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ class HttpToolkitServer extends Command {
4343 async run ( ) {
4444 const { flags } = this . parse ( HttpToolkitServer ) ;
4545
46+ this . setProcessTitle ( ) ;
47+
4648 this . cleanupOldServers ( ) ; // Async cleanup old server versions
4749
4850 await runHTK ( {
@@ -54,6 +56,20 @@ class HttpToolkitServer extends Command {
5456 } ) ;
5557 }
5658
59+ setProcessTitle ( ) {
60+ if ( process . platform === 'win32' ) return ; // Not possible on Windows, as far as I can tell.
61+
62+ // Set the process title for easier management in activity monitor etc. This has some limitations,
63+ // see https://nodejs.org/api/process.html#processtitle for details. In our case it's v likely to
64+ // work regardless, as the full paths used in the desktop app are fairly long already, plus the
65+ // path to the 'run' bin plus 'start', but we include a shorter fallback just in case too:
66+ const currentProcessTitle = [ process . argv0 , ...process . argv . slice ( 1 ) ] . join ( ' ' ) ;
67+ process . title = currentProcessTitle . length > 18
68+ ? "HTTP Toolkit Server"
69+ : "htk-server" ;
70+
71+ }
72+
5773 // On startup, we want to kill any downloaded servers that are not longer necessary
5874 async cleanupOldServers ( ) {
5975 if ( ! fs ) return ; // In node 8, fs.promises doesn't exist, so just skip this
You can’t perform that action at this time.
0 commit comments