I'm trying to install and use the `commandbox-serv...
# box-products
r
I'm trying to install and use the
commandbox-service-manager@ortus
module on macOS and get this...
Copy code
❯ install commandbox-service-manager@ortus --verbose --force
 √ | Installing package [forgebox:commandbox-service-manager@ortus]
   |---------------------------------------------------------------------------
   | Verifying package 'commandbox-service-manager@ortus' in forgebox, please wait...
   | Installing version [1.4.2].
   | Verified entry in forgebox: 'commandbox-service-manager@ortus'
   | Package found in local artifacts!
   | Decompressing...
   | /Volumes/sites/_commandbox/cfml/box.json updated with dependency.
   | Installing to: /Volumes/sites/_commandbox/cfml/modules/commandbox-service-manager@ortus
   | -> 39 File(s) Installed
   | -> 0 File(s) ignored
   | Eureka, 'commandbox-service-manager@ortus' has been installed!
   | Activating your new module for instant use...
   |---------------------------------------------------------------------------
bash: syntax error near unexpected token `('
I now get that bash error for all commands in the Box terminal.
b
@richard.herbert I assume the error is coming from the service check in bullet train
You can turn that car off in bullet train, but we need to find out what the error is
Turn on debugging for the module to see what commands it's trying to run
Also, what Operating System are you on?
Oh, you said MacOS. Mac support has been spotty for this module. it worked in older versions, but then Mac kept changing how their init system worked and we had issues on later versions of Mac.
No one has really ever tried to use it on Mac so it hasn't gotten much attention lately (and I don't use a Mac so I don't have a way to debug or test it)
r
Turn on debugging for the module to see what commands it's trying to run
Can you remind me how I turn on module debugging? Interestingly I have the use of two Macs, this only happens on one of them. Everything else seems to work just fine.
b
I assume your macs are different versions 🙂
You can always use tab complete to discover module settings.
Copy code
config set modules.commandbox-service-manager@ortus.debug=true
r
Both on the same OS version, one Intel, one Apple Silicon. Thanks for the snippet, not a area I've been in before. I'll let you know the result...
Copy code
Set modules.commandbox-service-manager@ortus.debug = true
run sudo launchctl list | grep Default-(default.localhost) || ( exit 0 > /dev/null )
bash: syntax error near unexpected token `('
b
Yep, all module settings are stored as config settings under the key
modules.nameOfMOdule.nameOfSetting
So if you start typing
Copy code
config set modules._
and hit tab, you'll see your options to start filtering on.
I assume
(default.localhost)
is the name of the CommandBox server or the name of the service.
And our code assumed that there wouldn't be any special characters in there
As parens are regex metachars
Yeah, that's the name of the service
r
Actually it's
"Default (default.localhost)"
b
Well, either way, I'm guessing your other machine doesn't have a funky name like that
r
True
So simplify the server name?
b
Yeah
r
Please hold...
b
We can fix this, but I'm not entirely clear if • a Mac service name can't have those chars • or if we just need to escape the strings
The service name is also used for file names on disk as well
i.e.
Copy code
function getServiceFileName( required string serviceName ) {
		return '/Library/LaunchDaemons/#serviceName#.plist';
	}
I'm not entirely sure what MacOS would do with a file name of
/Library/LaunchDaemons/#Default-(default.localhost)#.plist
I do replace spaces with hyphens in the service name, but that's all ATM
Which is why
Default (default.localhost)
showed up as
Default-(default.localhost)
in the bash command
Perhaps we should slugify it as well 🤔
I've normally only ever tested with basic named like
site1
, lol
You've heard the joke of the QA engineer who walks into a bar, orders a beer, then, 99999 beers, then -7 beers? 😆
Windows isn't quite as picky about its service names since it doesn't create files with them, just registry entries
r
Sure, but I'm just fancy 🙂 I think I'm going to have to take some timeout to clean up stuff, don't wait for me.
Windows isn't quite as picky about its service names since it doesn't create files with them, just registry entries
Yes, I also am using Service Manager on a Windows box, that's where I got my fancy service name habit from 🙂
So, it was my fancy service name that was causing the problem, thanks for the lead on that. With a simple service name I did find one issue, removing a service seems to fail...
Copy code
❯ server service create site1 --start
run sudo mv "/Volumes/sites/_commandbox/temp/FCF411A6-7DBB-4829-81F3EC127186339C.service" "/Library/LaunchDaemons/site1.plist"
run sudo chmod 755 /Library/LaunchDaemons/site1.plist
run sudo chown root /Library/LaunchDaemons/site1.plist
Service [site1] created!
Sending Service start control for [site1]
run sudo launchctl load /Library/LaunchDaemons/site1.plist
Service started!
run sudo launchctl list | grep rdh || ( exit 0 > /dev/null )
Copy code
❯ server service stop site1
Sending Service stop control for [site1]
run sudo launchctl unload /Library/LaunchDaemons/site1.plist
Service stopped!
run sudo launchctl list | grep rdh || ( exit 0 > /dev/null )
Copy code
❯ server service remove site1
run sudo launchctl list | grep site1 || ( exit 0 > /dev/null )
run sudo launchctl bootout system/site1
Boot-out failed: 3: No such process

ERROR (5.7.0+00653)

Error removing service file [/Library/LaunchDaemons/site1.plist]: Command returned failing exit code [3]

Please try as root. Error location: /Volumes/sites/_commandbox/cfml/system/BaseCommand.cfc:234

run sudo launchctl list | grep rdh || ( exit 0 > /dev/null )
That location seems to be the error handler, I'm not sure how to find where that sprang from. I am running CB as root
sudo box
b
The remove should have been this
Copy code
sudo launchctl bootout rdh
sudo rm -f "path-to-service-file"
Looks like the first command is the one that failed
Copy code
run sudo launchctl bootout system/site1
Boot-out failed: 3: No such process
I don't know enough about Mac services off the top of my head to understand what that means 🤔
Can you manually see if this command works in bash?
Copy code
sudo launchctl bootout system /Library/LaunchDaemons/site1.plist
Mac's service commands are confusing and poorly documented 😕
If that works, I'll have a new version of the module for you to test
I've also added a fix to escape regex metachars from the
grep
input. We only use
grep
on MacOs as the Linux system.d has better support
r
I think my system is getting very confused with all the starts/stops/removes. So flicking between the CommandBox terminal and my OS shell...
Copy code
❯ server service start site1
Sending Service start control for [site1]
Service started!
Copy code
sudo launchctl list | grep site1
40578	0	site1
sudo launchctl bootout system /Library/LaunchDaemons/site1.plist
sudo launchctl list | grep site1
And that seems to be gone but going back the CB...
Copy code
❯ server service status site1
Service name: site1

Service status: running

❯ server service stop site1
Sending Service stop control for [site1]
Service stopped!

❯ server service remove site1

ERROR (5.7.0+00653)

Error removing service file [/Library/LaunchDaemons/site1.plist]: Command returned failing exit code [3]

Please try as root. Error location: /Volumes/sites/_commandbox/cfml/system/BaseCommand.cfc:234
Bedtime here, I'll take another look tomorrow - thanks for your thoughts Brad
b
I'm not sure what all bootout does, but you never manually removed the plist file from disk so that's why the service is still defined!
But I think you've shown what I wanted to see, which is that the syntax of
Copy code
sudo launchctl bootout system /Library/LaunchDaemons/site1.plist
does work
@richard.herbert Tomorrow, please update to the latest version of that module and see how it works.
r
@bdw429s Sorry for not getting back to you sooner. I've taken the update to 1.4.4 and no better but different?
Copy code
❯ server cd "Default (default.localhost)"
> cd "/Volumes/sites/_default.localhost/webroot/"
/Volumes/sites/_default.localhost/webroot/bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

❯ config set modules.commandbox-service-manager@ortus.debug=true
Set modules.commandbox-service-manager@ortus.debug = true
run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

❯ server service remove rdh
run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

ERROR (5.7.0+00653)

Command returned failing exit code [2]

run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

sudo launchctl list | grep rdh
--- nothing returned ---

❯ pwd
/Volumes/sites/_default.localhost/webroot/
run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

With server.json starting...

{
    "name":"rdh",
    "openBrowser":"false",
    "web":{
        "host":"localhost",
        "http":{
            "port":"8500"
        },

❯ server start
 √ | Starting Server
   | √ | Setting Server Profile to [local]
   | √ | Installing package [java:openjdk11_jre_x64_mac_hotspot_jdk-11.0.7+10:lockVersion]
   | √ | Installing package [forgebox:lucee@5.3.7+48]
   | √ | Loading CFConfig into server

run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

❯ server list rdh
Processing (3) servers, please wait...

rdh (running)
  <http://localhost:8500>
  CF Engine: lucee 5.3.7+48
  Webroot: /Volumes/sites/_default.localhost/webroot/
  Last Started: 01-Feb-2023 17:49:10
run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

❯ server service create

ERROR (5.7.0+00653)

Service [rdh] already exists.  Please remove first or specify a different "servicename".

run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

❯ server service remove rdh
run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

ERROR (5.7.0+00653)

Command returned failing exit code [2]

run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file
A lot of stuff there but hopefully it might help?
Actually, looking at this...
run sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )
There's an extra quote
"rdh""
?
b
@richard.herbert Oh dear, yes that's a typo.
Sorry
This is what I get when I don't have a Mac to test on
pushing a new version now
r
Blind testing - not good 🙂
b
Can you try again? @richard.herbert
r
Can I get to this in a min...
@bdw429s Not seeing an update?
Copy code
commandbox-service-manager@ortus@^1.4.2 │ 1.4.4     │ 1.4.4  │ 1.4.4  │ /modules/commandbox-service-manager@ortus
b
Maybe it was cached
r
I tried this but no joy...
Copy code
❯ update commandbox-service-manager@ortus@1.4.5 --system
Resolving Dependencies, please wait...

ERROR (5.7.0+00653)

Package(s) [commandbox-service-manager@ortus@1.4.5] not found.

Use "outdated" to see what packages are available to update.  Only pass the package name to this command.
Copy code
❯ install commandbox-service-manager@ortus@1.4.5
 × | Installing package [forgebox:commandbox-service-manager@ortus@1.4.5]
   |---------------------------------------------------------------------------
   | Verifying package 'commandbox-service-manager@ortus' in forgebox, please wait...
   |---------------------------------------------------------------------------


ERROR (5.7.0+00653)

Version [1.4.5] not found for package [commandbox-service-manager@ortus].

Available versions are [ 1.4.4, 1.4.3, 1.4.2, 1.4.1, 1.4.0, 1.4.0-alpha, 1.3.5, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.6, 1.2.5, 1.2.4, 1.2.3, 1.2.1, 1.2.0, 1.2.0-beta, 1.1.2-beta, 1.1.1-beta, 1.1.0-beta, 1.0.3, 1.0.2, 1.0.1, 1.0.0, 0.6.0, 0.5.0, 0.2.0]
b
@richard.herbert Do you see it in the link I put above?
image.png
r
Yes but I thought if I tried to install the exact version it would resolve itself but no
b
(you'll need to be logged into forgebox, of course)
I see the new version in the CLI too
Copy code
❯ forgebox show commandbox-service-manager@ortus

Contacting ForgeBox, please wait...

 CommandBox Service Manager    ( Ortus Solutions, ortus )   Rating:

This module adds the ability for CommandBox to help you create and manage services for your servers.

...

Type: CommandBox Modules
Slug: "commandbox-service-manager@ortus"
Summary: A module to help manage services for CommandBox servers and more.
Versions:  1.4.5, 1.4.4, 1.4.3, 1.4.2, 1.4.1 ( 22 more...)
           0.6.0
           0.5.0
           0.2.0
Something must be cached.
r
Copy code
Type: CommandBox Modules
Slug: "commandbox-service-manager@ortus"
Summary: A module to help manage services for CommandBox servers and more.
Versions:  1.4.4, 1.4.3, 1.4.2, 1.4.1, 1.4.0 ( 21 more...)
           0.6.0
           0.5.0
           0.2.0
Created On: 11-Feb-19
Updated On: 12-Aug-22
ForgeBox Views: 247
Downloads: 0
Installs: 3,383
Home URL:
Source URL:
Bugs URL:
Documentation URL:
Indeed but how to break the cache?
b
I am dealing with an unrelated issue causing errors when I publish that @Javier Quintero is working on. I wonder if it's preventing our cache busting from working 🤔
Normally, Forgebox clears its cache after publishing a new version, but there's an unrelated ORM error happening when I publish
Luis has some "cache clear" buttons in the ForgeBox admin. Let me spam them a few times...
r
Thanks, no rush, I've plenty else to be getting on with 🙂
b
Can you run that CLI command above and see what you get?
r
What,
forgebox show commandbox-service-manager@ortus
? I did and posted the response - 1.4.4
b
I meant after I hit the button in the forgebox admin to clear the caches
You ran that prior to me clearing Forgebox's cache
(assuming those buttons work)
r
Sorry, that looks better...
Copy code
Type: CommandBox Modules
Slug: "commandbox-service-manager@ortus"
Summary: A module to help manage services for CommandBox servers and more.
Versions:  1.4.5, 1.4.4, 1.4.3, 1.4.2, 1.4.1 ( 22 more...)
           0.6.0
           0.5.0
           0.2.0
Created On: 11-Feb-19
Updated On: 12-Aug-22
ForgeBox Views: 252
Downloads: 0
Installs: 3,385
Home URL:
Source URL:
Bugs URL:
Documentation URL:
I'll try an update...
Yep, updated. Let me try some commands...
Copy code
❯ server service status
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

ERROR (5.7.0+00653)

Command returned failing exit code [2]

bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

❯ server service stop
Sending Service stop control for [rdh]
Service stopped!
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

❯ server service start
Sending Service start control for [rdh]
Service started!
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file
b
Can you turn the module debugging back on?
Without seeing what commands it's running, it's hard to say what's happening
r
Yes it is on...
Copy code
❯ config set modules.commandbox-service-manager@ortus.debug=true
Set modules.commandbox-service-manager@ortus.debug = true
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

❯ server service status
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

ERROR (5.7.0+00653)

Command returned failing exit code [2]

bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file

❯ server service stop
Sending Service stop control for [rdh]
Service stopped!
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file
b
Hmm, that's confusing then because the actual bash commands are not being output above
Try turning on debugging for native execution
Copy code
config set debugNativeExecution=true
That logs every native command that flows through the
run
command (which is what the service manger uses internally)
Until we know what command
bash: unexpected EOF while looking for matching "'
is referring to, we're just shooting in the dark
r
Copy code
❯ config set debugNativeExecution=true
Set debugNativeExecution = true
/bin/bash -i -c sudo launchctl list | grep "rdh"" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )
bash: unexpected EOF while looking for matching `"'
bash: syntax error: unexpected end of file
Still that extra
"
b
Hmm, doesn't seem like the command udpated.
That's not the new code 🤔
Does
Copy code
list --system
show the latest version and have you tried restarting the CLI?
r
Copy code
│   └── propertyFile (1.3.2)
├── commandbox-service-manager@ortus (1.4.5)
├─┬ commandbox-dotenv (2.3.0)
Let me quit box...
b
Line 272 of
modules/MacServiceManager.cfc
inside the module should be
Copy code
var rawStatus = trim( runNative( cmd='launchctl list | grep "#escapeRegex( ServiceName )#" || ( exit 0 > /dev/null )', forceReturn=true ) );
Notice there's only one double quote at the end of
Copy code
"#escapeRegex( ServiceName )#"
I downloaded the 1.4.5 artifact zip and verified that source code is correct
r
Okay, quitting Box helped...
Copy code
❯ server service status
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )
Service name: rdh

Service status: stopped

run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )

❯ server service stop
Sending Service stop control for [rdh]
run sudo launchctl unload /Library/LaunchDaemons/rdh.plist
/bin/bash -i -c sudo launchctl unload /Library/LaunchDaemons/rdh.plist  2>&1; ( exit $? > /dev/null )
/Library/LaunchDaemons/rdh.plist: Could not find specified service
Unload failed: 113: Could not find specified service
Service stopped!
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )

❯ server service start
Sending Service start control for [rdh]
run sudo launchctl load /Library/LaunchDaemons/rdh.plist
/bin/bash -i -c sudo launchctl load /Library/LaunchDaemons/rdh.plist  2>&1; ( exit $? > /dev/null )
Service started!
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )
I'm finished for the evening (UK). I'll wind back those debug setting and take another look tomorrow. Thanks for your help in working this out, Brad.
👍 1
@bdw429s Everything seems to be working expect
remove
(I am running as root)
Copy code
❯ config set debugNativeExecution=true
Set debugNativeExecution = true
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )

❯ config set modules.commandbox-service-manager@ortus.debug=true
Set modules.commandbox-service-manager@ortus.debug = true
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )

❯ server service status
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )
Service name: rdh

Service status: stopped

run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )

❯ server service start
Sending Service start control for [rdh]
run sudo launchctl load /Library/LaunchDaemons/rdh.plist
/bin/bash -i -c sudo launchctl load /Library/LaunchDaemons/rdh.plist  2>&1; ( exit $? > /dev/null )
Service started!
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )

❯ server service status
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )
Service name: rdh

Service status: running

run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )

❯ server service stop
Sending Service stop control for [rdh]
run sudo launchctl unload /Library/LaunchDaemons/rdh.plist
/bin/bash -i -c sudo launchctl unload /Library/LaunchDaemons/rdh.plist  2>&1; ( exit $? > /dev/null )
Service stopped!
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )

❯ server service status
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )
Service name: rdh

Service status: stopped

run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )

❯ server service remove rdh --force
run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )
run sudo launchctl bootout system "/Library/LaunchDaemons/rdh.plist"
/bin/bash -i -c sudo launchctl bootout system "/Library/LaunchDaemons/rdh.plist"  2>&1; ( exit $? > /dev/null )
/Library/LaunchDaemons/rdh.plist: Could not find specified service
Boot-out failed: 113: Unknown error: 113
Could not find service.

ERROR (5.7.0+00653)

Error removing service file [/Library/LaunchDaemons/rdh.plist]: Command returned failing exit code [113]

Please try as root. Error location: /Volumes/sites/_commandbox/cfml/system/BaseCommand.cfc:234

run sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )
/bin/bash -i -c sudo launchctl list | grep "rdh" || ( exit 0 > /dev/null )  2>&1; ( exit $? > /dev/null )