How Do I Stop My Project From the Shell?

Question:
What command in the shell would make my project stop running?

2 Likes

kill 1 kills the repl.
(If you are talking about Run/Stop button functionality, I have no idea.)

3 Likes

Yes, that is what I am thinking about.

Well, to stop your replit from the actual output, it’s CTRL + C (If that’s what you mean).
I doubt it’s possible from the shell to kill the run in general. Kill 1 kills the virtual linux machine (as @NuclearPasta0 mentioned), but I don’t think we can access whatever actually runs the code to cancel a specific file (I tried using ID and by name). Using pkill with parameters of one of the following: a, e, p, i, d, or w restarts the entire repl, but testing (with a python file), calling pkill .py, or pkill WHEEL, etc, had no effect at all.

4 Likes

Since the Stop button must do something to stop the repl, we might be able to use the same command if we knew about it and it isn’t internal.

1 Like

I did find something interesting just now. If you run the command [interpreter name (python3 for me)] [filepath], it runs the file without running the actual repl. The run button is still green and stuff, but a pygame window runs in the output…

I use it all the time to run specific files or even the python REPL/interactive.

Probably, the Run button sends a signal to directly kill the running process that was started by the .replit run command.

3 Likes

Yeah that makes sense. I wonder if the run button even uses a file. If you remember the domain topic, I mentioned how clientstream.launchdarkly allows for code to be ran through the cloud… If repl’s utilize that (which they probably do), it won’t be doable to kill it from the shell.

I’ll keep looking though. Maybe I’ll find something…

Not even that, it’s harsher than a normal kill signal. Normal kill signals could let you hook to them, the stop button doesn’t.

4 Likes

I’m not very good at reading html/javascript, so I can’t really tell… But if you inspect the stop button, it gives a file path. Are you able to tell where that path goes/what it executes (in which case maybe you could call a trigger to it)?

Looking through the network requests made when you run, I notice there’s pretty much three requests repeated a number of times.

The first is Google Analytics: https://www.google-analytics.com/collect?<and a bunch of parameters>.

The second is what I initially thought was Replit’s own analytics, but could be how the Repl is actually run: https://sp.replit.com/v1/t. It sends JSON looking like this:

{
	"timestamp": <just a timestamp string>,
	"integrations": {
		"Segment.io": true,
		"Amplitude": {
			"session_id": <a string id number>
		}
	},
	"userId": <my Replit ID as a string>,
	"anonymousId": <some id that looks kinda like part of a URL>,
	"event": "Workspace Port Opened", // other versions have the events `Project Ran`, `Packager Packages Guessed`, `Workspace Console Output Started`, `Workspace Webview Used`
	"type": "track",
	"properties": {
		"type": "webview",
		"replId": <the URL that is behind the webview, not the open in new tab URL>,
		"port": 3000,
		"externalPort": 80,
		"address": "::",
		"webviewAutoOpenOnPortOpened": true,
		"userAgent": <navigator.userAgent>
	},
	"context": {
		"ip": <my ip address>,
		"release": <some kind of release version>,
		"page": {
			"path": "/@<USERNAME>/<Repl name>",
			"referrer": <the page i came from>,
			"search": "",
			"title": <my Repl's title>,
			"url": <my Repl's URL>
		},
		"userAgent": <navigator.userAgent>,
		"userAgentData": <parsed userAgent>,
	"messageId": "ajs-next-<some id>",
	"writeKey": <some kind of secret/special token>,
	"sentAt": <a string timestamp>,
	// more Google stuff
	"_metadata": {
		"bundled": ["Google AdWords New", "Google Analytics", "Segment.io"],
		"unbundled": [],
		"bundledIds": ["<some kind of id>", "<some kind of id>"]
	}
}

The last one is just a GraphQL query (https://replit.com/graphql).

I notice it seems that in a single session the writeKey does not seem to change. When the event is Project Ran, there are some different properties:

{
	"language": "nix",
	"placement": "primary_btn",
	// (`replId`, same as previous)
	"replTitle": <my Repl name>,
	"rootOriginReplUrl": "/@<template author>/<template name>",
	"templateOwner": <the template author>,
	"templateTitle": <the template used>
}

It’s either this request or the GraphQL that runs the Repl, not 100% sure, but I suspect it’s this request.

2 Likes

These commands work, but they need to be put into one command:
ps -a (for python, it’s under python3)
kill <program process id>

EDIT: try ps -C python3

Okay, I did a little bit of linuxing, and came up with this command:
cat .replit | grep "run =" | grep -Po "(?<=\[[\"\']).*(?=[\"\'],)" | xargs -I{} pkill {}

If you know what command name (like python3) you repl is using already, use:
pkill <command name>

EDIT: if this is not working, check replit.nix. Some packages can stop this command from running.

3 Likes

Wow! That’s a long command – but it works! I will follow up here if I have any further questions. Thank you!

Sometimes, there is a syntax error, so if anyone wants to use this command, here is the command, just with the corrected syntax:

cat .replit | grep "run =" | cut -d \" -f 2 | xargs -I{} pkill -f {}
3 Likes

You’re welcome! Although the command still needs to be modified for old repls in nodejs, so I’m not sure if there is a more effective way to do it:

pkill node
1 Like

Neither - a Crosis client runs the Repl by sending a request

This client gets created when the Workspace starts loading.

Pretty sure you can grab the pure Websocket connection via a property on the window object but forgot what it’s called.

Edit: window.v8ws? Not entirely sure.

@MattDESTROYER @haroon There actually is a GQL request which can stop active repls (but it’s not used in the IDE). It’s triggered when you stop an active repl from the status page in your profile.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.