Good morning. I am using ComnandBox on Ubuntu 22.04, and working from singleServerMode
being set true
. I’m having trouble starting my CommandBox server as a system service. I’ve followed the steps on this page, but I’m having an issue.
My webroot is located at /web/default/wwwroot/
. My server.json
is located at /web/default/server.json
.
My mySite.service
looks like this:
[Unit]
Description=mySite.com Web Service
[Service]
User=ubuntu
Group=ubuntu
ExecStart=/usr/local/bin/box server start /web/default/server.json
Type=forking
[Install]
WantedBy=multi-user.target
When I try to start this with sudo systemctl start mySite.service
, I get this error, revealed with sudo systemctl status mySite.service
:
ubuntu@ip-172-26-9-15:~$ sudo systemctl status mySite.service
× mySite.service - mySite.com Web Service
Loaded: loaded (/lib/systemd/system/mySite.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2024-02-11 18:42:34 UTC; 21s ago
Process: 3224 ExecStart=/usr/local/bin/box server start /web/default/server.json (code=exited, status=1/FAILURE)
CPU: 23.174s
Feb 11 18:42:33 ip-172-26-9-15 box[3224]: called from /system/services/CommandService.cfc: line 443
Feb 11 18:42:33 ip-172-26-9-15 box[3224]: called from /system/services/CommandService.cfc: line 245
Feb 11 18:42:33 ip-172-26-9-15 box[3224]: called from /system/Shell.cfc: line 862
Feb 11 18:42:33 ip-172-26-9-15 box[3224]: called from /system/Bootstrap.cfm: line 124
Feb 11 18:42:33 ip-172-26-9-15 box[3224]:
Feb 11 18:42:33 ip-172-26-9-15 box[3224]: To enable full stack trace, run config set verboseErrors=true
Feb 11 18:42:34 ip-172-26-9-15 systemd[1]: mySite.service: Control process exited, code=exited, status=1/FAILURE
Feb 11 18:42:34 ip-172-26-9-15 systemd[1]: mySite.service: Failed with result 'exit-code'.
Feb 11 18:42:34 ip-172-26-9-15 systemd[1]: Failed to start mySite.com Web Service.
Feb 11 18:42:34 ip-172-26-9-15 systemd[1]: mySite.service: Consumed 23.174s CPU time.
ubuntu@ip-172-26-9-15:~$ /usr/local/bin/box server start /web/default/server.json
× | Starting Server
| > key [WEBROOT] doesn't exist
|------------------------------
ERROR (5.9.1+00767)
key [WEBROOT] doesn't exist
/modules/commandbox-dotenv/interceptors/LoadEnvPreServers.cfc: line 11
9:
10: function preServerStart(interceptData) {
11: var webRoot = variables.fileSystemUtil.normalizeSlashes( arguments.interceptData.serverDetails.serverInfo.webRoot );
12: var webRootEnvFile = webRoot.listAppend( variables.moduleSettings.fileName, "/", false );
13: var envStruct = variables.envFileService.getEnvStruct( webRootEnvFile );
called from /system/wirebox/system/core/events/EventPool.cfc: line 121
called from /system/wirebox/system/core/events/EventPool.cfc: line 95
called from /system/wirebox/system/core/events/EventPoolManager.cfc: line 59
called from /system/services/InterceptorService.cfc: line 57
called from /system/services/InterceptorService.cfc: line 61
called from /system/services/ServerService.cfc: line 352
called from /system/modules_app/server-commands/commands/server/start.cfc: line 171
called from /system/services/CommandService.cfc: line 443
called from /system/services/CommandService.cfc: line 245
called from /system/Shell.cfc: line 862
called from /system/Bootstrap.cfm: line 124
Just as additional hepful info, I tried running this command: /usr/local/bin/box server start /web/default/server.json
from the Ubuntu shell, and ran into the same error.
However, and this is the weird part, when I navigate in my shell to cd /web/default/
and just run box
, I am able to start CommandBox and run server start
, and the server starts with no trouble whatsoever.
My /web/default/server.json
looks like this:
{
"web":{
"webroot":"/web/default/wwwroot",
"HTTP":{
"enable":true,
"port":"8080"
},
"host":"0.0.0.0",
"welcomeFiles":"default.cfm",
"rewrites":{
"enable":"true"
},
"SSL":{
"certFile":"/etc/ssl/certs/mySite_com_chain.crt",
"keyFile":"/etc/ssl/private/mySite_com.key",
"enable":"true",
"port":"8081",
"forceSSLRedirect":"true"
},
"blockCFAdmin":"false",
"accessLogEnable":"true",
"gzipEnable":"true",
"blockSensitivePaths":"true",
"directoryBrowsing":"false"
},
"profile":"production",
"name":"wwwroot",
"openbrowser":"false",
"app":{
"cfengine":"lucee@5.4.4.38"
},
"env":{
"AWS_ACCESS_KEY_ID":"not_posting_this_obviously",
"AWS_SECRET_ACCESS_KEY":"not_posting_this_obviously"
},
"JVM":{
"heapSize":"512",
"properties":{
"java.awt.headless":"true"
},
"args":[
"-XX:+UseConcMarkSweepGC"
]
},
"fusionreactor":{
"port":"8088",
"enable":"false"
}
}
So I’m very, very confused as to what’s happening here. Any ideas or thoughts on why I’m able to start the server normally through the CommandBox CLI, but can not when it comes to running this as a service?
Thank you kindly for any help anybody can offer.