console command with readline
jl-nz
HOBBYOP

a year ago

hi all,

Is there a way to input console commands for my deployment, like you could with a regular node.js project locally?

the goal of what i'm doing is to be able to execute events via a console command at runtime.

Solved

18 Replies

jl-nz
HOBBYOP

a year ago

N/A


a year ago

ya, you can connect to the container's console via railway ssh

(make sure you have the latest cli installed)


jl-nz
HOBBYOP

a year ago

awesome, thank you.

I'm currently trying to test this using the following, but it doesn't seem to be working. I'm inputting "test" into the terminal after successfully connecting to the interactive shell

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', (message) => {
    console.log(`Input received: ${message}`);    
})

Is there a step I'm missing here to have this work with ssh? This works as expected when I test locally.


a year ago

You might have to spawn that interactive cli in the ssh cli after connecting to the container


jl-nz
HOBBYOP

a year ago

That sounds a bit beyond the scope of my current knowledge, is there any resource you could direct me to so that I can try figure that out?


a year ago

you just run your node app's cli after connecting to the container


a year ago

I'm not sure of your workflow, though personally if I had to make this then I'd have two entrypoints in my app

the main entrypoint, which is my actual application, then a second cli entrypoint that I can run myself, like node cli.js


a year ago

-# I could be fully wrong here, I've never done this before since I've never needed to make an interactive CLI for a production application hosted elsewhere


jl-nz
HOBBYOP

a year ago

oh okay, i think i get what you're meaning, thanks for your help


a year ago

np!!


jl-nz
HOBBYOP

a year ago

This does seem to work, though i'll have to figure out how/if i can integrate it with my existing project (for anyone who finds this via search)


a year ago

yea true, that is the only issue with this approach though I can't think of another way to tackle this


a year ago

(again though I've never done this before so there could be better ways but this is what I'd do personally)


a year ago

hosting a CLI application on a web hosting platform is definitely not what railway ssh is intended to be used for


a year ago

sometimes you gotta swat flies with a sledgehammer


a year ago

sometimes you gotta swat flies with a sledgehammer


a year ago

feel free to mark as solved fragly


a year ago

!s


Status changed to Solved dev about 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...