My web app no longer runs

I’ve been playing around with my first web target. I’ve got a Lightsail server running and successfully deployed my app to it. Now I’ve made some changes to my app and re-deployed it but it no longer runs on the server. It still runs locally without issue.

I get the javascript black box error with “This application has encountered an error and cannot continue” as the title and the first error line is “Could not execute returned javascript: Can’t find variable: textlabel”.

Initially the variable was “timer” and so I thought I must have an issue with the (only) WebTimer on my single-page app and deleted that control. Then the error seems to have “moved” to the next control.

I’m guessing that there’s no error with the named variable and there’s something else at play here?

I tried creating a blank web page and setting that as the startup page and my app would then run.

So then I tried adding a single label control to the new blank page and, as soon as I did that, my app would no longer run. The error log is:

Could not execute returned javascript: Can't find variable: textlabel Source: Xojo.view.confirmationText = "You are about to leave the app..."; Xojo.events.setSessionTimeout(300); new textlabel('xNbBH5Sa',['TextChanged']); Xojo.controls['xNbBH5Sa'].setEnabled(true); new frameworkObject('T2kgeJrC',['Close','Open','Shown']); Xojo.controls['T2kgeJrC'].setEnabled(true); Xojo.view.showPage('T2kgeJrC'); document.title = "Untitled"; Xojo.view.dismissLoader();

If I change the single control on the page from a label to a button, the first line of the error log changes to:

Can't find variable: button

The above log is on Safari. If I try it on Chrome the first line changes to:

Could not execute returned javascript: button is not defined

OK it seems I’m having the issue mentioned here: https://forum.xojo.com/51675-daemonize-on-debian-causes-internal-server-error/0

If I remove this code from my App Open event, then the pages load fine:

// Daemonize app If Not DebugBuild Then Call Daemonize End If

But I need to Daemonize the app, otherwise as soon as I close the terminal window the app also terminates.

Standalone can be daemonized, cgi-builds are already daemonized by xojo.

The error looks like you set a button or control in the open event instead of the shown event.

No it’s due to this bug: <https://xojo.com/issue/54491>

How do you start the application? using Systemd or manually over the terminal/console ?

How are you launching the app when you do?

For instance, have you tried:

nohup myapplication &

I’ve got a little script that kills the process, copies the new version of the app, sets the permissions and then restarts nginx.

I’m just starting the app with:

sudo ./{pathToApp}/{appName} --port=8080

As per the Feedback, starting the app with the full path seems to fix the problem.

Here’s something I’ve found. My app sets its SQLite database location like this:

file = SpecialFolder.CurrentWorkingDirectory.Child("Dashboard.sqlite")

This works fine in debug mode but not in my AWS Lightsail (EC2) instance. My app and database are in their own folder off the user’s home folder and, even though I am executing the app from within that folder, SpecialFolder.CurrentWorkingDirectory is returning the root folder. I think that might be because I’m executing it with “sudo”?

When I tried using “nohup” instead, my app never launched. I also tried SpecialFolder.UserHome.Child(“Dashboard.sqlite”) and it also returns the root folder. So I wound up having to hardcode the database location.

Yup. That would do it.

Try

App.ExecutableFile.Parent.Child(“Dashboard.sqlite”)