Worked it out - no SPACES... set myVar=myValue ...
# cfml-general
g
Worked it out - no SPACES... set myVar=myValue works set myVar = myValue doesnt --------------- A quick off-topic question... How do I set and use an environment variable in windows (11) DOS? The following doesn't work - but I am sure it is exactly what I have done before, successfully - and Mr.Google appears to agree with me. set myEnvVar = 'thisIsMyValue' echo %myEnvVar% All it does is print %myEnvVar% - and not the value. Thanks!
b
Copy code
set myEnvVar=thisIsMyValue
👍🏼 1
g
Thanks @bdw429s Basically I am trying to see if a named instance of a box server is running already. I have this;
Copy code
FOR /F "tokens=*" %g IN (`wmic PROCESS where "name like '%java%' and CommandLine like '%surveyEngine%'" get ProcessId`) DO (SET var=%g)
ECHO %var%
But the because the command actually returns 3 rows output, the second being the ID
Copy code
) Users\gavin>(SET var=ProcessId

 ) Users\gavin>(SET var=4964

 ) Users\gavin>(SET var=
The actual value I am getting back is not a process ID. in fact running echo %var% give me
echo is on.
All I am trying to do is to see if there is a process running already before I attempt to stop it. Or rather - only attempt to stop it - if it is actually running. Because the batch file is individual "box" command lines - it take a little while spawn the box process and get a result - so I am just trying to speed up the process.
b
@gavinbaumanis I'm confused why you'd go through all that trouble, when you could just ask the server if it's running!
Copy code
server info name=your-server-name property=status
Which will output
running
or
stopped
And if you want the process ID of a server, just run
Copy code
server info name=cfconfig property=pidfile | cat
Which will output the PID or nothing (if stopped)
g
@bdw429s but that would be extra "box" commands - which is time expensive - because of having to load the box executable So I was trying to get an already running or not, status, more quickly. Realistically... I can just leave it as is - it works and it's (guessing) around 20 seconds extra... First world problems right? I just don't like things getting the better of me, either - though.... so once I got it into my head that I wanted to a status check first - it bugs me I cant do it.
b
I would still use the PID file on disk
They're in a predicable place for each server and you can always get the PID from it
The file is deleted when the server stops
You can read that file without invoking box
For the record, I do dislike the fact that the CLI startup time is still so slow it prevents people from wanting to run it 😕
But there's not much I can do there sadly
g
Things run really smoothly / quickly - if you start a box session and do everything "within" it.. Recipes - work awesomely well.
👍 1
it really is a problem of my own making. The only reason I have 3 apps running is because I'm too lazy to put the work into making a docker image that will do the url -> app mapping for the 3 different apps... and I don't want to run IIS. . - so I just run 3 instances on different ports, configuring them and starting them via recipes / batch files. The smart money would be to create a docker image that has nginx / mysql (mariaDB) and commandBox (luceee) But I haven't done an awesome amount with docker - and while certainly not a waste of time - I just don't have the time to invest in docker shenanigans, right now.
b
@gavinbaumanis If it would simplify your setup, you could power all 3 sites with a single CommandBox instance using the ModCFML feature. With a bit of config, you can even make it work without IIS/Apache/etc in front
👍🏼 1