anvil-works / anvil-runtime Goto Github PK
View Code? Open in Web Editor NEWThe runtime engine for hosting Anvil web apps
Home Page: https://anvil.works/open-source
License: Other
The runtime engine for hosting Anvil web apps
Home Page: https://anvil.works/open-source
License: Other
Hi, I am running my app with anvil-app-server. When I try to send an e-mail to my app like this:
@anvil.email.handle_message
def message_handler(msg):
to_address = msg.addressees.to_addresses[0].raw_value
msg.reply(text=f"Your email was sent to {to_address} and received successfully.")
I receive a 554 Internal server error e-mail reply and I see this error on console:
Calling function 'email:handle_message' for app 'CSI' (ID server-uB4YgU1H/iznMA==)
[ERROR anvil.dispatcher.native-rpc-handlers.util] Internal server error: 0ce41c78b6d1
java.lang.UnsupportedOperationException
at anvil.app_server.secrets$get_global_app_secret_value.invokeStatic(secrets.clj:64)
at anvil.app_server.secrets$get_global_app_secret_value.invoke(secrets.clj:64)
at anvil.dispatcher.native_rpc_handlers.email$send_BANG_$fn__18699.invoke(email.clj:171)
at anvil.dispatcher.native_rpc_handlers.email$send_BANG_.invokeStatic(email.clj:171)
at anvil.dispatcher.native_rpc_handlers.email$send_BANG_.invoke(email.clj:80)
at anvil.dispatcher.native_rpc_handlers.email$wrapped_send$fn__18798$fn__18799.invoke(email.clj:214)
at anvil.core.worker_pool$with_expanding_threadpool_when_slow_STAR_.invokeStatic(worker_pool.clj:117)
at anvil.core.worker_pool$with_expanding_threadpool_when_slow_STAR_.invoke(worker_pool.clj:104)
at anvil.dispatcher.native_rpc_handlers.email$wrapped_send$fn__18798.invoke(email.clj:213)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at anvil.dispatcher.native_rpc_handlers.util$wrap_native_fn$fn__6969$fn__6972$fn__6981.invoke(util.clj:83)
at anvil.dispatcher.native_rpc_handlers.util$wrap_native_fn$fn__6969$fn__6972.invoke(util.clj:82)
at clojure.lang.AFn.run(AFn.java:22)
at anvil.core.worker_pool$run_one_task_BANG_.invokeStatic(worker_pool.clj:48)
at anvil.core.worker_pool$run_one_task_BANG_.invoke(worker_pool.clj:32)
at anvil.core.worker_pool$launch_thread_BANG_$fn__5895.invoke(worker_pool.clj:86)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:748)
[ERROR anvil.app-server.run] Error report from server code:
anvil.server.InternalError: Internal server error: 0ce41c78b6d1
Traceback:
/home/jbk/anvil/venv/lib/python3.8/site-packages/anvil_downlink_worker/anvil/_threaded_server.py:412
/home/jbk/anvil/venv/lib/python3.8/site-packages/anvil_downlink_worker/anvil/server.py:47
/home/jbk/anvil/venv/lib/python3.8/site-packages/anvil_downlink_worker/anvil/email.py:37
/home/jbk/anvil/venv/lib/python3.8/site-packages/anvil_downlink_worker/anvil/email.py:149
/home/jbk/anvil/CSI/server_code/ServerModule1.py:25
/home/jbk/anvil/venv/lib/python3.8/site-packages/anvil_downlink_worker/anvil/email.py:46
Worker terminated for IDs set() (return code None)
What do I do wrong, please? Thanks
From the documentation it's not clear to me how I would be able to get access to the console App Log of a running app. From the source code I can see app_log.clj
and logging.clj
but it's unclear how I'd configure the server to send app logging to the server logs. Is there some way to do this with log4j
configuration?
I am getting the following error. Running on macOS .
Can you please prescribe the java / python version needed to run this?
bash-3.2# anvil-app-server --app MyTodoList
Found Anvil App Server JAR in package directory
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.bouncycastle.jcajce.provider.drbg.DRBG (file:/usr/local/lib/python2.7/site-packages/anvil_app_server/anvil-app-server.20200506-125042.jar) to constructor sun.security.provider.Sun()
WARNING: Please consider reporting this to the maintainers of org.bouncycastle.jcajce.provider.drbg.DRBG
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
ERROR - #error {
:cause Process [.anvil-data/db-bin/PG-2c0c4f55a015ab253337e3d05ca5fd21/bin/initdb, -A, trust, -U, postgres, -D, .anvil-data/db, -E, UTF-8] failed
:via
[{:type java.lang.IllegalStateException
:message Process [.anvil-data/db-bin/PG-2c0c4f55a015ab253337e3d05ca5fd21/bin/initdb, -A, trust, -U, postgres, -D, .anvil-data/db, -E, UTF-8] failed
:at [io.zonky.test.db.postgres.embedded.EmbeddedPostgres system EmbeddedPostgres.java 631]}]
:trace
[[io.zonky.test.db.postgres.embedded.EmbeddedPostgres system EmbeddedPostgres.java 631]
[io.zonky.test.db.postgres.embedded.EmbeddedPostgres initdb EmbeddedPostgres.java 249]
[io.zonky.test.db.postgres.embedded.EmbeddedPostgres <init> EmbeddedPostgres.java 156]
[io.zonky.test.db.postgres.embedded.EmbeddedPostgres$Builder start EmbeddedPostgres.java 584]
[anvil.app_server.postgres$launch_bundled_db_BANG_ invokeStatic postgres.clj 70]
[anvil.app_server.postgres$launch_bundled_db_BANG_ invoke postgres.clj 20]
[anvil.app_server.run$_main$fn__1692 invoke run.clj 373]
[clojure.lang.AFn applyToHelper AFn.java 154]
[clojure.lang.AFn applyTo AFn.java 144]
[clojure.core$apply invokeStatic core.clj 659]
[clojure.core$update_in$up__6562 invoke core.clj 6105]
[clojure.core$update_in invokeStatic core.clj 6106]
[clojure.core$update_in doInvoke core.clj 6092]
[clojure.lang.RestFn invoke RestFn.java 445]
[anvil.app_server.run$_main invokeStatic run.clj 373]
[anvil.app_server.run$_main doInvoke run.clj 220]
[clojure.lang.RestFn applyTo RestFn.java 137]
[anvil.app_server.run main nil -1]]}
bash-3.2# java -version
java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing)
Hello.
I am working from the example services
to configure a users service in a dummy test app (based on the app-structure.yaml docs), but it seems that no users
table is created. Here is the print out when the app is first called:
Database is uninitialised. Setting up Anvil database from scratch...
Setup complete.
[INFO anvil.core.server] HTTP Server running on port 3030
[INFO anvil.app-server.run] App URL: http://localhost:3030
[INFO anvil.app-server.dispatch] Launching built-in downlink...
[INFO anvil.app-server.run] SMTP Server running on port 25
Connecting to ws://localhost:3030/_/downlink
Anvil websocket open
Here is the anvil.yaml
:
dependencies: []
services:
- source: /runtime/services/tables.yml
client_config: {}
server_config: {auto_create_missing_columns: false}
- source: /runtime/services/anvil/users.yml
client_config: {use_microsoft: false, require_secure_passwords: true, share_login_status: false,
use_email: true, allow_remember_me: true, allow_signup: true, enable_automatically: false,
confirm_email: false, remember_me_days: 7, use_google: false, use_facebook: false}
server_config: {user_table: 'users'}
package_name: MyCRUDApp
allow_embedding: false
name: My CRUD App
runtime_options: {version: 2, client_version: '3', server_version: python3-sandbox}
metadata: {}
startup_form: Form1
db_schema:
- name: tasks
id: 12345
python_name: tasks
columns:
E9e2ASS2uyU=:
name: name
type: string
admin_ui: {order: 0, width: 200}
Lk958fQHwJ0=:
name: complete
type: bool
admin_ui: {order: 0, width: 200}
access: {python_name: tasks, app_id: MyCRUDApp, server: full, client: none,
table_id: 12345}
renamed: true
This is the code that I am trying to run:
print("Adding admin user")
app_tables.users.add_row(email = "[email protected]",
password="my_super_secret_password",
enable=True)
And, here is the error I am getting:
[ERROR anvil.app-server.run] Error report from client code:
AnvilWrappedError: No such app table: 'users'
Unsure why the error is in the client code. The call is done in a server module.
Do I need to explicitly create a schema for the table?
I am using version 1.1 of app server and python 3.7.7.
Thank you.
Anders.
I was not aware that running anvil-app-server
without any parameters would download the app server's JAR file until I noticed this line in the packaging Dockerfile.
Unless I've missed it, I think this is worth mentioning in the documentation; or even making an explicit flag that only downloads the JAR file and doesn't try to start an app in the current directory.
We develop locally using Docker and having to wait for the JAR file to download when a container restarts is cumbersome. It's also nice to have an image with the app server already included for production. I think other people would benefit from this feature being included in the documentation.
Hi administrator,
I tried to test the default anvil-app with a super user name 'tzuser', but it gave me the following error:
(venv) tzuser@mysite:~/venv$ sudo anvil-app-server --app MyTodoList
Found Anvil App Server JAR in package directory
Failed to start built-in Postgres database: java.lang.IllegalStateException: Process [.anvil-data/db-bin/PG-a8263178df5b3591feca6b619939c2bb/bin/initdb, -A, trust, -U, postgres, -D, .anvil-data/db, -E, UTF-8] failed
More logs are available in .anvil-data/postgres.log.
Some common causes of this problem:
Please advice, thanks.
$ anvil-app-server --smtp-host ${HOST} --smtp-port 587 --smtp-username ${MY_USER} --smtp-password ${MY_PASSWORD} --smtp-encryption ssl
Found Anvil App Server JAR in package directory
Failed to validate "--smtp-encryption ": Expected 'ssl' or 'starttls'
1 error(s)
Unknown argument(s): ssl
Note that doing --smtp-encryption=ssl also doesn't work, nor does starttls.
As a dedicated Anvil developer, when I use an UPDATE SQL statement to set a Link column to NULL, the value should be cleared and the link removed.
TO REPRODUCE:
InternalError: Cannot update links to other rows using SQL. Please use the Python Data Tables API.
CONTEXT: PL/pgSQL function data_tables.table_104880_update() line 13 at RAISE
EXPECTED BEHAVIOR
The lookup_option
value of the data_cache
table should be set to None.
In looking at the anvil-server code, it looks like this error is being generated by an automated PostgreSQL table trigger defined in runtime/tables/util.clj
line 770. (as of git commit 44b3f5e)
... (Table trigger definition)
(->> (for [col view-cols
:let [COL-NAME (:VIEW-NAME col)
ERR (get {"liveObject" "Cannot update links to other rows using SQL. Please use the Python Data T
"liveObjectArray" "Cannot update links to other rows using SQL. Please use the Python Data T
"media" "Cannot update Media objects in Data Tables using SQL. Please use the Python Data Tables API."}
(:type col))]
:when ERR]
(str "IF (NEW." COL-NAME " != OLD." COL-NAME ") OR (NEW." COL-NAME " IS NULL AND OLD." COL-NAME " IS NOT NULL) OR (NEW." COL-NAME " IS NOT NULL AND OLD." COL-NAME " IS NULL) THEN RAISE EXCEPTION '" ERR "'; END IF;"))
(interpose "\n")
(apply str))
Based on my read of this code, I think the logic needs to be inverted such that if setting the value to NULL, then allow the update, otherwise RAISE an exception.
Is this something that should be fixed, or is working as designed?
Hi,
I've moved from windows 10 to linux ubuntu and the local server is working OK until
I tried to login using email address.
Originally, I setup my account in the app (using free acount) and then git cloned my app into local server.
When I try to launch my app (which has email/password login option), it won't let me login using my ID and password.
First, I saw that the email server was not set correctly and I set up an SendGrid SMTP relay.
Then, if I try to login using my ID (that I've created on Anvil Server), it asks me to confirm my email inbox, and I see no email from my app.
My local server anvil.yaml file looks correct as it shows all the values I've typed in.
In logging.cl there is an appender to send errors to a log file.
Could we please have a startup option to set the log level (with the current 'error' as default)?
When using User Service, with remember me box checked, the app works fine on the hosted app, but not with the open source one
We have a yaml file with the following SMTP options:
smtp-host: example.net
smtp-port: 465
smtp-encryption: ssl
smtp-username: [email protected]
smtp-password: example_password
This works fine for anvil-app-server
1.4, however using 1.5.x produces the following the error:
InternalError: No SMTP server has been configured for this app
Traceback:
/opt/bitnami/python/lib/python3.7/site-packages/anvil_downlink_worker/anvil/_threaded_server.py:404
/opt/bitnami/python/lib/python3.7/site-packages/anvil_downlink_worker/anvil/server.py:40
/opt/bitnami/python/lib/python3.7/site-packages/anvil_downlink_worker/anvil/email.py:37
AusTrakka/UserManagementServer.py:241
AusTrakka/UserManagementServer.py:377
app/AusTrakka/Utils/Users/UserAdmin.py:266
app/AusTrakka/Utils/Users/UserLogin.py:54
app/AusTrakka/HomeForm/__init__.py:91
Passing these as CLI options produces the same result.
I got the following error when connecting the remote Postgres database
[ERROR anvil.app-server.run] #error {
:cause clojure.lang.PersistentArrayMap cannot be cast to java.lang.String
:via
[{:type java.lang.ClassCastException
:message clojure.lang.PersistentArrayMap cannot be cast to java.lang.String
:at [clojure.java.jdbc$get_connection invokeStatic jdbc.clj 381]}]
:trace
[[clojure.java.jdbc$get_connection invokeStatic jdbc.clj 381]
[clojure.java.jdbc$get_connection invoke jdbc.clj 274]
[clojure.java.jdbc$db_query_with_resultset_STAR_ invokeStatic jdbc.clj 1100]
[clojure.java.jdbc$db_query_with_resultset_STAR_ invoke jdbc.clj 1082]
[clojure.java.jdbc$query invokeStatic jdbc.clj 1171]
[clojure.java.jdbc$query invoke jdbc.clj 1133]
[clojure.java.jdbc$query invokeStatic jdbc.clj 1149]
[clojure.java.jdbc$query invoke jdbc.clj 1133]
[migrator.migrations$is_db_empty_QMARK_ invokeStatic migrations.clj 65]
[migrator.migrations$is_db_empty_QMARK_ invoke migrations.clj 63]
[migrator.core$migrate_BANG_$fn__862$fn__864 invoke core.clj 27]
[migrator.core$migrate_BANG_$fn__862 invoke core.clj 26]
[migrator.core$migrate_BANG_ invokeStatic core.clj 25]
[migrator.core$migrate_BANG_ invoke core.clj 20]
[anvil.app_server.run$_main$fn__1706 invoke run.clj 423]
[anvil.app_server.run$_main invokeStatic run.clj 422]
[anvil.app_server.run$_main doInvoke run.clj 224]
[clojure.lang.RestFn applyTo RestFn.java 137]
[anvil.app_server.run main nil -1]]}
I have specified my own SMTP server in anvil online editor. Sending via the online interface works fine. When I run the app locally on the anvil runtime server, I get the following error message:
[DEBUG anvil.dispatcher.core] Dispatch! anvil.private.email.send.v2 for feedback_form
[ERROR anvil.dispatcher.native-rpc-handlers.util] Internal server error: 6b3710419637
java.lang.UnsupportedOperationException
at anvil.app_server.secrets$get_global_app_secret_value.invokeStatic(secrets.clj:64)
at anvil.app_server.secrets$get_global_app_secret_value.invoke(secrets.clj:64)
at anvil.dispatcher.native_rpc_handlers.email$send_BANG_$fn__17149.invoke(email.clj:170)
at anvil.dispatcher.native_rpc_handlers.email$send_BANG_.invokeStatic(email.clj:170)
at anvil.dispatcher.native_rpc_handlers.email$send_BANG_.invoke(email.clj:79)
at anvil.dispatcher.native_rpc_handlers.email$wrapped_send$fn__17246$fn__17247.invoke(email.clj:211)
at anvil.core.worker_pool$with_expanding_threadpool_when_slow_STAR_.invokeStatic(worker_pool.clj:75)
at anvil.core.worker_pool$with_expanding_threadpool_when_slow_STAR_.invoke(worker_pool.clj:64)
at anvil.dispatcher.native_rpc_handlers.email$wrapped_send$fn__17246.invoke(email.clj:210)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at anvil.dispatcher.native_rpc_handlers.util$wrap_native_fn$fn__12245$fn__12248$fn__12257.invoke(util.clj:82)
at anvil.dispatcher.native_rpc_handlers.util$wrap_native_fn$fn__12245$fn__12248.invoke(util.clj:81)
at clojure.lang.AFn.run(AFn.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:313)
at anvil.core.worker_pool$fn__3737$fn__3738$fn__3739$fn__3740.invoke(worker_pool.clj:28)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Worker terminated for IDs set() (return code -9)
[ERROR anvil.app-server.run] Error report from client code:
InternalError: Internal server error: 6b3710419637
Traceback:
/home/ladmin/anvil/venv/lib/python3.8/site-packages/anvil_downlink_worker/anvil/_threaded_server.py:402/home/ladmin/anvil/venv/lib/python3.8/site-packages/anvil_downlink_worker/anvil/server.py:38
/home/ladmin/anvil/venv/lib/python3.8/site-packages/anvil_downlink_worker/anvil/email.py:21
/home/ladmin/anvil/feedback_form/server_code/ServerModule1.py:29
app/feedback_form/Form1/init.py:26
The entry point psql-anvil-app-server
currently uses the command line tool psql
.
pgcli might be a better option because:
psql
I'm happy to put together a PR for this if there's support for the notion.
I have my own certificate and am specifying the cert path and key path. However, when using these settings the app is not reachable via the internet. Using the lets-encrypt-staging flag works though.
Here is how I'm declaring these in the config yml:
manual-cert-file: "certificate.crt"
manual-cert-key-file: "private.key"
It seems that though the anvil app server is detecting that it needs to create a new database schema to match the db schema in anvil.yaml file .. I am not sure why it is not actually creating the database tables.
(env) [anvil@centos-s-1vcpu-1gb-sfo2-01 ~]$ anvil-app-server --app AppName
Found Anvil App Server JAR in package directory
Found 0 migration(s) for (base runtime) DB.
Executing Anvil migrations...
Database currently at "2019-09-23-B-denormalise-app-sessions"
0 migration(s) to perform.
Migration complete.
[INFO anvil.app-server.tables] Data tables schema out of date. Here is the migration that will run if you restart Anvil with the --auto-migrate command-line flag:
[INFO anvil.app-server.tables] [{:action :CREATE_TABLES,
:tables
[{:name "Users",
:python_name "users",
:columns
{:2VPIoU_AbJA= {:name "confirmed_email", :type "bool"},
:jDH+c99C97U= {:name "signed_up", :type "datetime"},
:OEnitU_Fgww= {:name "email", :type "string"},
:3jjf5ujVRBo= {:name "last_login", :type "datetime"},
:UI2UuNFwbKE= {:name "password_hash", :type "string"},
:l5UP2NSaULI= {:name "org_admin", :type "bool"},
:ElnQjNWzsnI= {:name "org_secret", :type "string"},
:oR_SZCt6e_8= {:name "enabled", :type "bool"},
:Upn8nGLgXXc= {:name "email_confirmation_key", :type "string"}},
:id 43256}
{:name "Mapps",
:python_name "mapps",
:columns
{:+Ymexr_i19Y= {:name "AppLink", :type "string"},
:fMrCfXSZTJE= {:name "AppName", :type "string"},
:qyWimtt13b8= {:name "AppDescription", :type "string"},
:vAqiX7y_vsY= {:name "AppLogo", :type "media"}},
:id 43257}
{:name "Subscriptions",
:python_name "subscriptions",
:columns
{:+Aqae_poB3k= {:name "UnsubscribedOn", :type "datetime"},
:AfJo5PK3ypY= {:name "Status", :type "bool"},
:NloOoR9WLHg=
{:name "User",
:type "liveObject",
:backend "anvil.tables.Row",
:table_id 43256},
:Y2SA7nVg_Do= {:name "Role", :type "string"},
:aWRr0oCV16I=
{:name "App",
:type "liveObject",
:backend "anvil.tables.Row",
:table_id 43257},
:hVVPlpKw2lk= {:name "Plan", :type "string"},
:qD9a5z7TB7w= {:name "SubscribedOn", :type "datetime"}},
:id 43263}]}
{:action :DELETE_TABLE, :python_name "Users"}
{:action :DELETE_TABLE, :python_name "MApps"}
{:action :DELETE_TABLE, :python_name "Subscriptions"}]
[INFO anvil.app-server.tables] Anvil will now exit. Run with --ignore-invalid-schema to startup anyway.
(env) [anvil@centos-s-1vcpu-1gb-sfo2-01 ~]$ vim AppName/anvil.yaml
(env) [anvil@centos-s-1vcpu-1gb-sfo2-01 ~]$ anvil-app-server --app AppName --auto-migrate
Found Anvil App Server JAR in package directory
Found 0 migration(s) for (base runtime) DB.
Executing Anvil migrations...
Database currently at "2019-09-23-B-denormalise-app-sessions"
0 migration(s) to perform.
Migration complete.
[INFO anvil.core.server] HTTP Server running on port 3030
[INFO anvil.app-server.run] App URL: http://localhost:3030
[INFO anvil.app-server.dispatch] Launching built-in downlink...
[ERROR anvil.app-server.run] Failed to start mail server on port 25 - this application will not be able to receive email: java.net.BindException: Permission denied (Bind failed)
[INFO anvil.app-server.run] SMTP Server running on port 25
Connecting to ws://localhost:3030/_/downlink
Anvil websocket open
[INFO anvil.executors.downlink] Downlink client connected with spec {:runtime "python3-full", :session_id "39l6SLgVHEZ50ovMUUnn"}
Downlink authenticated OK
[TRACE anvil.runtime.util] Creating new session oyhixitc3z7d3xtuetjts42d for app AppName replacing NONE (new session)
[DEBUG anvil.runtime.server] Serving app AppName
[INFO anvil.app-server.run] [LOG :new-session] {:type browser}
[TRACE anvil.runtime.util] Using existing session oyhixitc3z7d3xtuetjts42d (last accessed 1589059140817, app id AppName)
[DEBUG anvil.dispatcher.core] Dispatch! get_all_apps for AppName
Calling function 'get_all_apps' for app 'AppName' (ID client-SlfJ5uZVdq1ooFKdChEU4Q==)
[DEBUG anvil.dispatcher.core] Dispatch! anvil.private.tables.get_app_tables for AppName
Worker terminated for IDs set() (return code -15)
[ERROR anvil.app-server.run] Error report from client code:
AnvilWrappedError: No such app table: 'mapps'
Traceback:
/home/anvil/env/lib64/python3.6/site-packages/anvil_downlink_worker/anvil/tables/__init__.py:20
/home/anvil/AppName/server_code/basic_utils.py:24
app/AppName/AppDashboard_v1.py:15
app/AppName/splash_1.py:32
Hi there,
Big fan of your app server and anvil.works. I've successfully launched several apps on windows and linux builds, however I am having issues with my new mac air with the M1 chip.
After activating the virtual environment, installing anvil-app-server and creating a test app, when I launch I get the following error:
Failed to start built-in Postgres database: java.lang.IllegalStateException: Missing postgres binaries
More logs are available in .anvil-data/postgres.log.
Some common causes of this problem:
- Are you launching this server as 'root' on a UNIX system?
Postgres will not run as root; try launching the server as an ordinary user.- Are you running this server on an unusual architecture or OS? (Mac OS X/aarch64)
further, when opening the .anvil-data log the following warnings are displayed:
[INFO io.zonky.test.db.postgres.embedded.EmbeddedPostgres] Detected a Darwin aarch64 system
[INFO io.zonky.test.db.postgres.embedded.DefaultPostgresBinaryResolver] Detected distribution: 'Unknown'
[TRACE io.zonky.test.db.postgres.embedded.DefaultPostgresBinaryResolver] Searching for postgres binaries - location: 'postgres-darwin-arm_64.txz'
[ERROR io.zonky.test.db.postgres.embedded.DefaultPostgresBinaryResolver] No postgres binaries were found, you must add an appropriate maven dependency that meets the following parameters - system: Darwin, architecture: arm_64
I suspect this is an issue with the postgressql package and the macosx, however I am far from an expert, I'd love to get any pointers :)
Some SMTP hosts (including mine) do not allow the email from_address to be an alias or a different to the SMTP User.
The hard coded "from_address" causes an error in this case.
An e-mail "from_address" config option would be useful here.
[ERROR anvil.app-server.run] Error report from client code:
AnvilWrappedError: Invalid Addresses
Traceback:
<rpc>:0
anvil-services/anvil/users.py:63
anvil-services/anvil/users.py:469
anvil-services/anvil/users.py:469
app/CC_Test/Form1/__init__.py:15
I think this section of code shows the hard coding but it's only a guess.
From core.clj Line 232:
(defn send-email! [to subject text]
(if (get-in @util/*session-state* [:users :test-email-divert])
(swap! util/*session-state* update-in [:users :test-email-divert] concat [{:to to, :subject subject, :text text}])
(binding [email/*use-quota* false
email/*require-service-config* false]
(email/send! {:from_name (if (app-data/abuse-caution? util/*session-state* util/*app-id*)
"Accounts"
(str (:name util/*app*) " Accounts"))
:from_address "accounts"
:to to
:subject subject
:text text}))))
Hi.. I would like to know if there is anvil gui /web builder for offline editing?
What I did
smtp-host: smtp.sendgrid.net
smtp-port: 465
smtp-user: apikey
smtp-encryption: ssl
smtp-password:
launched MyApp (has email/passwd auth) using
anvil-app-server --config-file smtp.yaml --app MyApp
everything works fine upto this point
did pw reset using forgot my password link in the login form
MyApp sent me an email, and the link in the email looks something like this:
You have requested a password reset for your account: [email protected]
when I click above link from a remote pc, the link starts with
localhost:3030/_/email-pw-reset/blahblahblah --> which obviously does not work cause i'm remote.
I changed the localhost part to the external ip of my local server manually, and then it worked.
So, what I'm wondering is, if there is a way that I can tweak a little bit so that my pw reset link points to the external ip address as a default link.
So, in a nutshell,
instead this pw reset link ( localhost:3030//email-pw-reset/blahblahblah ),
how can I send to user a pw reset link with externalIP:3030//email-pw-reset/blahblahblah
Trying the minimal example fails with the following error
Any guidance on this?
pip install anvil-app-server
create-anvil-app todo-list MyTodoList
anvil-app-server --app MyTodoList
Error:
(venv) user@machine:~/projects/anvil-server$ anvil-app-server
Downloading Anvil App Server JAR to package directory
Failed to download App Server to package directory. Retrying in ~/.anvil
Traceback (most recent call last):
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/urllib/request.py", line 1350, in do_open
h.request(req.get_method(), req.selector, req.data, headers,
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/http/client.py", line 1255, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/http/client.py", line 1301, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/http/client.py", line 1250, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/http/client.py", line 1010, in _send_output
self.send(msg)
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/http/client.py", line 950, in send
self.connect()
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/http/client.py", line 1424, in connect
self.sock = self._context.wrap_socket(self.sock,
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/ssl.py", line 1040, in _create
self.do_handshake()
File "/z/datalake/virtual_envs/20201117T185046/Ubuntu18.04/lib/python3.8/ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1124)
Hi guys,
Being able to write development tools with anvil within our firewall is exactly what we needed! Great respect for open-sourcing the runtime.
We are running all our software on Kubernetes and are interested in making a streamlined deployment process for our anvil apps.
What would you recommend for this? Should we bake all the apps in a single docker image or should we write a controller that interacts with the runtime to add and update apps? Or perhaps we should go 1 app, 1 runtime?
I'm curious to your views on this and will of course push my charts (and controller if necessary) upstream.
here a copy of my config.yaml
app: voltage_forecast_demo
uplink-key: A4
port: 3000
ip: 0.0.0.0
origin: https://novum-batteries.com/anvil
disable-tls: true
I have nginx proxying the https requests to an anvil docker. nginx is also doing the https stuff. So i have disable-tls: true.
And when i check the page html i get
<!DOCTYPE html>
<html lang="en" class="no-js runner">
<head>
<base href="http://novum-batteries.com:80/">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="expires" content="0">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="referrer" content="never"> <!-- Yes, this is "legacy", but Safari and Edge don't support 'no-referrer' yet -->
<meta name="og:title" content="Novum Demo App">
<meta name="og:type" content="website">
<meta name="og:url" content="http://novum-batteries.com:80">
<meta name="og:image" content="/_/static/img/logo-square-padded.png">
...
origin seems to be ignored completely.
The canonical-url var from server.clj should take this into account.
Any thoughts on this? Would be nice to have that path feature to deploy anvil apps.
thx neppi
In order to sign up a new user a verification needs to be sent. For QA testing we're using a local fake SMTP but the Anvil runtime cannot connect to is. This is possibly a duplicate of #6 Below were the steps I took to reproduce it:
New Blank App
" and add the Users
service and in __init__
of From1
add:user = anvil.users.login_with_form()
Clone the repo to a local machine
Install fake-smtp-server
via npm
and start it on port 1025
.
Download anvil-app-server and run local instance of app using:
anvil-app-server --smtp-host localhost --smtp-port 1025 --smtp-username foo --smtp-password bar
Attempt to sign up as a new user.
Observe following stack trace:
Found Anvil App Server JAR in package directory
Database is uninitialised. Setting up Anvil database from scratch...
Setup complete.
[INFO anvil.core.server] HTTP Server running on port 3030
[INFO anvil.app-server.run] App URL: http://localhost:3030
[INFO anvil.app-server.dispatch] Launching built-in downlink...
Warning: PDF Rendering not supported on Windows. Renderer not initialised
Connecting to ws://localhost:3030/_/downlink
Anvil websocket open
[INFO anvil.executors.downlink] Downlink client connected with spec {:runtime "python3-full", :session_id "7RgfxJjQzjJkOxSAp3tL"}
Downlink authenticated OK
[INFO anvil.app-server.run] SMTP Server running on port 25
[TRACE anvil.runtime.util] Creating new session pozbv5av4ekact4z3anaibls for app Example_User_Login replacing NONE (new session)
[DEBUG anvil.runtime.server] Serving app Example_User_Login
[INFO anvil.app-server.run] [LOG :new-session] {:type browser}
[TRACE anvil.runtime.util] Using existing session pozbv5av4ekact4z3anaibls (last accessed 1589380502355, app id Example_User_Login)
[TRACE anvil.runtime.util] Using existing session pozbv5av4ekact4z3anaibls (last accessed 1589380503502, app id Example_User_Login)
[DEBUG anvil.runtime.server] Couldn't load app nil
[TRACE anvil.runtime.util] Creating new session 3bilz7jfp4ejq3pbbvnhevyx for app Example_User_Login replacing NONE (new session)
[DEBUG anvil.dispatcher.core] Dispatch! anvil.private.users.get_current_user for Example_User_Login
[DEBUG anvil.dispatcher.core] Dispatch! anvil.private.users.get_last_login_email for Example_User_Login
[DEBUG anvil.dispatcher.core] Dispatch! anvil.private.users.signup_with_email for Example_User_Login
[INFO anvil.runtime.tables.rpc] Loading table rows (3 ms)
[INFO anvil.runtime.tables.rpc] Loading table rows (1 ms)
[DEBUG anvil.app-server.run] [SERVER] Automatically creating column "signed_up" (datetime)
[DEBUG anvil.app-server.run] [SERVER] Automatically creating column "password_hash" (string)
[DEBUG anvil.app-server.run] [SERVER] Automatically creating column "confirmed_email" (bool)
[DEBUG anvil.app-server.run] [SERVER] Automatically creating column "email_confirmation_key" (string)
[ERROR anvil.dispatcher.native-rpc-handlers.util] Internal server error: b22f691f8b3e
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number
at anvil.dispatcher.native_rpc_handlers.email$smtp_send.invokeStatic(email.clj:291)
at anvil.dispatcher.native_rpc_handlers.email$smtp_send.invoke(email.clj:227)
at anvil.dispatcher.native_rpc_handlers.email$send_BANG_.invokeStatic(email.clj:164)
at anvil.dispatcher.native_rpc_handlers.email$send_BANG_.invoke(email.clj:78)
at anvil.dispatcher.native_rpc_handlers.users.core$send_email_BANG_.invokeStatic(core.clj:237)
at anvil.dispatcher.native_rpc_handlers.users.core$send_email_BANG_.invoke(core.clj:232)
at anvil.dispatcher.native_rpc_handlers.users.core$signup_with_email.invokeStatic(core.clj:261)
at anvil.dispatcher.native_rpc_handlers.users.core$signup_with_email.invoke(core.clj:245)
at clojure.lang.AFn.applyToHelper(AFn.java:160)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:659)
at clojure.core$apply.invoke(core.clj:652)
at anvil.dispatcher.native_rpc_handlers.util$wrap_native_fn$fn__12201$fn__12204$fn__12213.invoke(util.clj:79)
at anvil.dispatcher.native_rpc_handlers.util$wrap_native_fn$fn__12201$fn__12204.invoke(util.clj:78)
at clojure.core$binding_conveyor_fn$fn__5476.invoke(core.clj:2022)
at clojure.lang.AFn.call(AFn.java:18)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
[ERROR anvil.app-server.run] Error report from client code:
InternalError: Internal server error: b22f691f8b3e
Traceback:
anvil-services/anvil/users.py:307
anvil-services/anvil/users.py:307
anvil-services/anvil/users.py:477
anvil-services/anvil/users.py:477
app/Example_User_Login/Form1/__init__.py:17
The code that produces this error is here: https://github.com/anvil-works/anvil-runtime/blob/master/server/core/src/anvil/dispatcher/native_rpc_handlers/email.clj#L291
This appears to be an issue with the Java Mail Api.
I got an error when I use
anvil-app-server --app
The error message complains about postgres binaries
and I don't see any documentation regarding this error message.
(anvil) D:\anvil-runtime>anvil-app-server --app Classic_3
Found Anvil App Server JAR in package directory
ERROR - #error {
:cause Missing postgres binaries
:via
[{:type java.lang.IllegalStateException
:message Missing postgres binaries
:at [io.zonky.test.db.postgres.embedded.DefaultPostgresBinaryResolver getPgBinary DefaultPostgresBinaryResolver.java 68]}]
:trace
[[io.zonky.test.db.postgres.embedded.DefaultPostgresBinaryResolver getPgBinary DefaultPostgresBinaryResolver.java 68]
[io.zonky.test.db.postgres.embedded.EmbeddedPostgres prepareBinaries EmbeddedPostgres.java 767]
[io.zonky.test.db.postgres.embedded.EmbeddedPostgres EmbeddedPostgres.java 130]
[io.zonky.test.db.postgres.embedded.EmbeddedPostgres$Builder start EmbeddedPostgres.java 584]
[anvil.app_server.postgres$launch_bundled_db_BANG_ invokeStatic postgres.clj 70]
[anvil.app_server.postgres$launch_bundled_db_BANG_ invoke postgres.clj 20]
[anvil.app_server.run$_main$fn__1692 invoke run.clj 373]
[clojure.lang.AFn applyToHelper AFn.java 154]
[clojure.lang.AFn applyTo AFn.java 144]
[clojure.core$apply invokeStatic core.clj 659]
[clojure.core$update_in$up__6562 invoke core.clj 6105]
[clojure.core$update_in invokeStatic core.clj 6106]
[clojure.core$update_in doInvoke core.clj 6092]
[clojure.lang.RestFn invoke RestFn.java 445]
[anvil.app_server.run$_main invokeStatic run.clj 373]
[anvil.app_server.run$_main doInvoke run.clj 220]
[clojure.lang.RestFn applyTo RestFn.java 137]
[anvil.app_server.run main nil -1]]}
We have an SMTP server defined for our application on the Anvil IDE. When we pull this locally we want to be able to pass our own server details for testing purposes.
I have a config file defined locally with the following fields:
smtp-host: smtp.sendgrid.net
smtp-port: 465
smtp-encryption: ssl
smtp-username: xxxx
smtp-password: xxxx
The official SMTP is still defined locally in the anvil.yaml
file. I would expect the settings in the config file to override these in the anvil.yaml
, however it seems to ignore them unless I remove the mail settings in anvil.yaml
.
Hi! I've previously posted this issue in the anvil-extras repo.
As instructed by the team over there I solved the issue temporarily by using a previous version of that repo (1.5.2 instead of 1.6).
I was told by them the issue is the app server is not updated. I figured it's worth raising the issue here in case anyone else runs into it while this gets solved (I guess you guys must have your hands full with that new awesome editor!).
The error thrown when starting the app server was the following:
[ERROR anvil.app-server.run] Error report from client code:
AttributeError: module 'js' has no attribute 'await_promise'
Traceback:
app/anvil_extras/utils/_component_helpers.py:56
app/anvil_extras/MultiSelectDropDown/init.py:32
app/gen_propuestas_anvil/Home/init.py:18
Thanks!
When I Upgrade to anvil-app-server 1.6.5 [latest Version on pip] - not all Elements appear on the rendered PDF.
When I switch back to version 1.6.2 all elements are rendered as they should.
Hi,
I created the Hello_World sample in the online editor, exported it and ran locally with anvil-app-server --app Hello_World
and everything worked as expected.
I spun up a local standalone Postgres database and tried to use that with the same app: anvil-app-server --app Hello_World --database "jdbc:postgresql://localhost/<db>?user=<user>&password=<pass>"
And am getting this error:
Found Anvil App Server JAR in package directory
Found 0 migration(s) for (base runtime) DB.
Executing Anvil migrations...
Database currently at "2019-09-23-B-denormalise-app-sessions"
0 migration(s) to perform.
Migration complete.
[ERROR anvil.app-server.run] #error {
:cause ERROR: relation "scheduled_tasks" does not exist
Position: 41
:via
[{:type org.postgresql.util.PSQLException
:message ERROR: relation "scheduled_tasks" does not exist
Position: 41
:at [org.postgresql.core.v3.QueryExecutorImpl receiveErrorResponse QueryExecutorImpl.java 2497]}]
:trace
[[org.postgresql.core.v3.QueryExecutorImpl receiveErrorResponse QueryExecutorImpl.java 2497]
[org.postgresql.core.v3.QueryExecutorImpl processResults QueryExecutorImpl.java 2233]
[org.postgresql.core.v3.QueryExecutorImpl execute QueryExecutorImpl.java 310]
[org.postgresql.jdbc.PgStatement executeInternal PgStatement.java 446]
[org.postgresql.jdbc.PgStatement execute PgStatement.java 370]
[org.postgresql.jdbc.PgPreparedStatement executeWithFlags PgPreparedStatement.java 149]
[org.postgresql.jdbc.PgPreparedStatement executeQuery PgPreparedStatement.java 108]
[sun.reflect.NativeMethodAccessorImpl invoke0 NativeMethodAccessorImpl.java -2]
[sun.reflect.NativeMethodAccessorImpl invoke NativeMethodAccessorImpl.java 62]
[sun.reflect.DelegatingMethodAccessorImpl invoke DelegatingMethodAccessorImpl.java 43]
[java.lang.reflect.Method invoke Method.java 498]
[net.ttddyy.dsproxy.proxy.StatementProxyLogic performQueryExecutionListener StatementProxyLogic.java 316]
[net.ttddyy.dsproxy.proxy.StatementProxyLogic access$700 StatementProxyLogic.java 37]
[net.ttddyy.dsproxy.proxy.StatementProxyLogic$1 execute StatementProxyLogic.java 123]
[net.ttddyy.dsproxy.listener.MethodExecutionListenerUtils invoke MethodExecutionListenerUtils.java 42]
[net.ttddyy.dsproxy.proxy.StatementProxyLogic invoke StatementProxyLogic.java 120]
[net.ttddyy.dsproxy.proxy.jdk.PreparedStatementInvocationHandler invoke PreparedStatementInvocationHandler.java 37]
[com.sun.proxy.$Proxy4 executeQuery nil -1]
[com.mchange.v2.c3p0.impl.NewProxyPreparedStatement executeQuery NewProxyPreparedStatement.java 353]
[clojure.java.jdbc$execute_query_with_params invokeStatic jdbc.clj 1079]
[clojure.java.jdbc$execute_query_with_params invoke jdbc.clj 1073]
[clojure.java.jdbc$db_query_with_resultset_STAR_ invokeStatic jdbc.clj 1095]
[clojure.java.jdbc$db_query_with_resultset_STAR_ invoke jdbc.clj 1082]
[clojure.java.jdbc$query invokeStatic jdbc.clj 1171]
[clojure.java.jdbc$query invoke jdbc.clj 1133]
[clojure.java.jdbc$query invokeStatic jdbc.clj 1149]
[clojure.java.jdbc$query invoke jdbc.clj 1133]
[anvil.runtime.cron$update_cron_jobs_BANG_$fn__5640$fn__5641 invoke cron.clj 67]
[clojure.java.jdbc$db_transaction_STAR_ invokeStatic jdbc.clj 806]
[clojure.java.jdbc$db_transaction_STAR_ invoke jdbc.clj 776]
[clojure.java.jdbc$db_transaction_STAR_ invokeStatic jdbc.clj 841]
[clojure.java.jdbc$db_transaction_STAR_ invoke jdbc.clj 776]
[anvil.runtime.cron$update_cron_jobs_BANG_$fn__5640 invoke cron.clj 66]
[anvil.runtime.cron$update_cron_jobs_BANG_ invokeStatic cron.clj 66]
[anvil.runtime.cron$update_cron_jobs_BANG_ invoke cron.clj 65]
[anvil.app_server.run$load_main_app invokeStatic run.clj 100]
[anvil.app_server.run$load_main_app invoke run.clj 93]
[anvil.app_server.run$_main invokeStatic run.clj 429]
[anvil.app_server.run$_main doInvoke run.clj 224]
[clojure.lang.RestFn applyTo RestFn.java 137]
[anvil.app_server.run main nil -1]]}
I assume that the migrations to setup the scheduled_tasks
table aren't being applied - any idea on how I should do that? I can see the tables defined in the builtin Postgres database but feel that it would be too hacky to manually apply those definitions to my new standalone database.
For reference here is my anvil.yaml
:
allow_embedding: false
package_name: Hello_World
db_schema:
- name: Users
id: 64914
python_name: users
columns:
BKbqJK5LK_g=:
name: last_login
type: datetime
admin_ui: {order: 3, width: 200}
_GYmkUpHj4E=:
name: enabled
type: bool
admin_ui: {order: 1, width: 100}
iBV4NpzRhe8=:
name: email
type: string
admin_ui: {order: 0, width: 200}
qpg9O_JnRc0=:
name: signed_up
type: datetime
admin_ui: {order: 2, width: 200}
access: {python_name: users, app_id: OD6RICKBZAOJ7GN4, server: full, client: none,
table_id: 64914}
name: Hello World
startup_form: Form1
renamed: true
runtime_options: {version: 2, client_version: '3', server_version: python3-sandbox}
services:
- source: /runtime/services/tables.yml
client_config: {}
server_config: {auto_create_missing_columns: false}
- source: /runtime/services/anvil/users.yml
client_config: {allow_signup: true, enable_automatically: true, use_email: false,
confirm_email: false, use_google: true}
server_config: {user_table: users}
- source: /runtime/services/google.yml
client_config: {}
server_config: {}
After listening to a podcast, I tried creating a virtual env (conda py 3.7) and installed/ran the todo application on my personal Mac (Catalina).
I can't find a description of how to fully uninstall it. After removing the virtual environment and fully removing the contents of the temporary application directory for the todo application, the route http://127.0.0.1:3030 continues to serve up content including javascript to connect to services like Stripe even after a reboot. This is quite alarming.
How can I reverse this without having to do a complete reinstall of Catalina or reversion to a recent Time Machine backup?
Update:
Anvil is installing a persistent service worker to support "PWA". See comment below to clear the data associated with it.
Note that this means any Chrome browser that visits the application will have this running until you do clear it.
We ran an anvil app and tried to use ngrok to access the Internet, but Anvil doesn't change the port number for assets. I'm not sure about other parts because I can't even login
I used only uplink-key, auto-migrate and SMTP flags in the config file
Take a look at the images
We tried to run the app on Windows 10, on Windows 10 + WSL 2, and on Ubuntu 16.04 LTS, results were the same always
On my Mac, python
executable is the system python2
. to get to python3
I use the exec python3
(installed via homebrew).
But, running:
anvil-app-server --app MyTodoList
Fails with the following issue:
[INFO anvil.app-server.dispatch] Launching built-in downlink...
/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named anvil_downlink_host
Which suggests the runtime is looking for anvil_downlink_host
in the wrong location, as I installed anvil-runtime-server
in my homebrew installation.
So, I ran brew info python3
and picked up the bin folder that has python
linked to my brew installation and then ran:
PATH=/usr/local/opt/python/libexec/bin:$PATH anvil-app-server --app MyTodoList
I was then able to get things to work.
This is a perennial issue with Python never enforcing python3
as the proper executable name.
Thought others might find this helpful.
Thank you for releasing Anvil as open-source! Very excited to give it a go.
PS. System info:
usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Library/Apple/usr/bin
When running the app server on Windows 10 some characters, such as umlauts, display incorrectly due to Windows default CP-1252 encoding.
In the command prompt (for a single session) you may use:
set _JAVA_OPTIONS=%_JAVA_OPTIONS% -Dfile.encoding=UTF-8
Or you may set an according environment variable in your Windows account.
The below code works find on the cloud Anvil but get error when using the Anvil App Server v1.6.5
@anvil.server.callable
def my_login(email, password):
user = app_tables.users.get(email=email)
if user is not None:
print (type(user))
#anvil.users.force_login(user)
#anvil.users.login_with_email(email=email, password = password,remember=True)
else:
return "Wrong info"
anvil.users.login_with_email(email=email, password = password,remember=True)
TableError: This table cannot be written or searched by this app
anvil.users.force_login(user)
InternalError: force_login() must be passed a row from the users table
After logging into the postgres database, I can see the app table names listed as string values inside the โapp_storage_access tableโ. But how to access the data rows from these tables such as โusersโ using โpsqlโ command from the terminal window. Are these tables stored in the local server or remotely in the Anvil.Works server? Any ideas would be appreciated.
anvil-app-server --app MyApp --origin 1.1.1.1
my ip is 48.1.1.1.1 and the above-mentioned command works without any issue. The app run perfectly well. 1.1.1.1 can be replaced by any ip
Not sure if it is a bug?
I got the app server to work on Linux and it is a really elegant solution with everything packaged in one installation and for the full stack!
It does however require manual user startup through the:
anvil-app-server --app
command and I would like to get it to start up with the Linux OS. I tried using a systemd service:
[Unit]
Description=Anvil Material_Design_1
After=multi-user.target
[Service]
Type=idle
ExecStart=/home/anvil/env/bin/python /home/anvil/env/bin/anvil-app-server --app Material_Design_1 > /home/anvil/Material_Design_1.log 2>&1
WorkingDirectory=/home/anvil
User=anvil
[Install]
WantedBy=multi-user.target
but it does not start successfully as a service and I get the following error:
Material_Design_1.service - Anvil Material_Design_1
Loaded: loaded (/etc/systemd/system/Material_Design_1.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2021-09-21 17:13:29 SAST; 22min ago
Sep 21 17:13:29 raspberrypi python[12481]: --microsoft-app-id APP_ID App ID to use for Microsoft authentSep 21 17:13:29 raspberrypi systemd[1]: Material_Design_1.service: Main process exited, code=exited, status=1/FAILURE
Sep 21 17:13:29 raspberrypi systemd[1]: Material_Design_1.service: Failed with result 'exit-code'.
The manual startup from the terminal does work.
Is there perhaps a solution or guide on how to get the app server to start automatically with startup of the OS?
Thanks
Deal Anvil,
I am new to Anvil, sorry this is not an issue but more a question of how to use, hoping I am in the right place.
I would like to serve my app to public internet (so that I can use uplink from another machine), however my host machine is under a network using DDNS service, I can't figure how should I configure.
My host machine OS:
Ubuntu 20.04.3
I have done the followings:
echo 'net.ipv4.ip_unprivileged_port_start=0' > /etc/sysctl.d/50-unprivileged-ports.conf
anvil-app-server --app MyApp
Then I tried the following commands to make my app accessible from outside, but all failed
anvil-app-server --app MyApp --origin http://0.0.0.0 --port 443
anvil-app-server --app MyApp --origin https://0.0.0.0 --port 443
anvil-app-server --app MyApp --origin https://my-domain-name-ddns-gives --port 443
would you please teach me how should I configure/use ?
Many thanks!
When using the dockerfile from this repo, I get a permissions error when the container starts (as it attempts to download the App Server JAR).
During the build, the JAR downloaded successfully.
Downloading Anvil App Server JAR to package directory
Failed to download App Server to package directory. Retrying in ~/.anvil
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/anvil_app_server/__init__.py", line 167, in find_or_download_app_server
_urlretrieve(url, package_dir_path, show_progress)
File "/usr/local/lib/python3.8/urllib/request.py", line 257, in urlretrieve
tfp = open(filename, 'wb')
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.8/site-packages/anvil_app_server/anvil-app-server.20200515-134353.jar'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/anvil-app-server", line 8, in <module>
sys.exit(launch())
File "/usr/local/lib/python3.8/site-packages/anvil_app_server/__init__.py", line 12, in launch
jar_path = find_or_download_app_server()
File "/usr/local/lib/python3.8/site-packages/anvil_app_server/__init__.py", line 172, in find_or_download_app_server
_urlretrieve(url, home_dir_path, show_progress)
File "/usr/local/lib/python3.8/urllib/request.py", line 257, in urlretrieve
tfp = open(filename, 'wb')
FileNotFoundError: [Errno 2] No such file or directory: '/home/anvil/.anvil/anvil-app-server.20200515-134353.jar'
When running my anvil app on a local server I get the following error when trying to make an API Call:
Client-Browser: "No matching API endpoint"
Server-Log: "anvil.server.NoServerFunctionError: API request routing failed. No @anvil.server.http_endpoint exists with math matching '...'"
However, when I run it in the hosted environment it works fine.
Any Ideas about what might be the problem?
a useful javascript function would be to have
anvil.getElement(python_object) // must be an instance of Component (or an anvil_wrapped Component)
in a similar way to how
anvil.call
is used (only on the javascript side)
happy to make this PR.
Hello.
I ran into an issue where I was trying to add a row to a table in the database, but one of the fields did not exist and I had disabled automatic column creation.
The error from the App and the console in the terminal was:
ExecutionTerminatedError: Server code exited unexpectedly: 60b51b0138
After I ran it with the --shell
and manually added data to the table I got this much more helpful error message:
anvil._server.AnvilWrappedError: anvil.tables.NoSuchColumn: "Row update failed: Column 'valid_until' does not exist and automatic column creation is disabled."
It would be helpful to see these messages when in a DEV environment, but not a PROD one.
Thank you.
Anders.
https://anvil-runtime-cla.anvil.app/ just loads a blank page for me.
There seems to be a regression in 1.6.0 in the DB schema check to decide when a migration is necessary. This issue is not present in 1.5.5.
I run anvil-app-server
version 1.6.0 on a container with a host directory volume for the database, and on first start it successfully creates the database and everything works, but if I kill the container and start it again it doesn't recognize the schema and suggests all kinds of crazy changes.
Pinning anvil-app-server
to 1.5.5 on the pip installation in the Dockerfile
and repeating the same procedure works fine.
Example of the suggested migration when there have been no changes to the DB schema in anvil.yaml
:
Found 2 migration(s) for (base runtime) DB.
Executing Anvil migrations...
Database currently at "2021-06-19-runtime-sessions"
0 migration(s) to perform.
Database now at "2021-06-19-runtime-sessions"
Migration complete.
[TRACE anvil.app-server.run] Invalidating; new version 1
[INFO anvil.app-server.tables] Data tables schema out of date. Here is the migration that will run if you restart Anvil with the --auto-migrate command-line flag:
[INFO anvil.app-server.tables] ({:type :UPDATE_TABLE, :table "providers", :title "Providers"}
{:type :DELETE_COLUMN, :table "providers", :column_name "name"}
{:type :DELETE_COLUMN, :table "providers", :column_name "image_link"}
{:type :DELETE_COLUMN, :table "providers", :column_name "driver_name"}
{:type :DELETE_COLUMN, :table "providers", :column_name "vat_id"}
{:type :DELETE_COLUMN, :table "providers", :column_name "address"}
{:type :DELETE_COLUMN,
:table "providers",
:column_name "country_code"}
{:type :DELETE_COLUMN, :table "providers", :column_name "website"}
{:type :ADD_COLUMN,
:table "providers",
:column
{:name "user",
:admin_ui {:width 200},
:type "link_single",
:target "users"}}
{:type :ADD_COLUMN,
:table "providers",
:column
{:name "display_name", :admin_ui {:width 200}, :type "string"}}
{:type :ADD_COLUMN,
:table "providers",
:column {:name "config", :admin_ui {:width 200}, :type "string"}}
{:type :ADD_COLUMN,
:table "providers",
:column {:name "created", :admin_ui {:width 200}, :type "datetime"}}
{:type :ADD_COLUMN,
:table "providers",
:column {:name "updated", :admin_ui {:width 200}, :type "datetime"}}
{:type :ADD_COLUMN,
:table "providers",
:column
{:name "provider_info",
:admin_ui {:width 200},
:type "link_single",
:target "providerinfo"}}
{:type :UPDATE_TABLE, :table "users", :title "Users"}
{:type :DELETE_COLUMN, :table "users", :column_name "image_link"}
{:type :DELETE_COLUMN, :table "users", :column_name "driver_name"}
{:type :DELETE_COLUMN, :table "users", :column_name "vat_id"}
{:type :DELETE_COLUMN, :table "users", :column_name "address"}
{:type :DELETE_COLUMN, :table "users", :column_name "country_code"}
{:type :DELETE_COLUMN, :table "users", :column_name "website"}
{:type :ADD_COLUMN,
:table "users",
:column {:name "email", :admin_ui {:width 200}, :type "string"}}
{:type :ADD_COLUMN,
:table "users",
:column {:name "enabled", :admin_ui {:width 100}, :type "bool"}}
{:type :ADD_COLUMN,
:table "users",
:column
{:name "signed_up", :admin_ui {:width 200}, :type "datetime"}}
{:type :ADD_COLUMN,
:table "users",
:column
{:name "last_login", :admin_ui {:width 200}, :type "datetime"}}
{:type :ADD_COLUMN,
:table "users",
:column
{:name "password_hash", :admin_ui {:width 200}, :type "string"}})
[INFO anvil.app-server.tables] Anvil will now exit. Run with --ignore-invalid-schema to startup anyway, or --auto-migrate to apply the changes above.
Link to a forum post of another user experiencing the same issue when migrating to 1.6.0
I have a need to build an Anvil application that can work as a Saas. One of the more critical parts is the implementation with-in the client's organization. My familiarity lies mostly with Java J2EE and this one a common pattern that is used e.g. SAML support. I;m looking to replace these applications with an Anvil stack. I took a look at the source and how one might accomplish this given the framework but it would appear the best place would be as a service part of the anvil runtime. I found an example of SAML+Clojure here https://github.com/quephird/saml-test
The above link provides what's needed to test SAML integration along with what lib to use Clojure.
I got the following error when run pip install anvil-app-server in the fresh VPS Ubuntu 18.04
copying psutil/tests/main.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_system.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/runner.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_unicode.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_windows.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_posix.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_contracts.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_memleaks.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_linux.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_aix.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_sunos.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_osx.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_testutils.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_misc.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_bsd.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/init.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_process.py -> build/lib.linux-x86_64-3.6/psutil/tests
copying psutil/tests/test_connections.py -> build/lib.linux-x86_64-3.6/psutil/tests
running build_ext
building 'psutil.psutil_linux' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/psutil
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat
-Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPSUTIL_POSIX=1 -DPSUTIL_SIZEOF_PID
T=4 -DPSUTIL_VERSION=572 -DPSUTIL_LINUX=1 -DPSUTIL_ETHTOOL_MISSING_TYPES=1 -I/usr/include/python3.6m
-I/home/tony/venv/include/python3.6m -c psutil/_psutil_common.c -o build/temp.linux-x86_64-3.6/psut
il/_psutil_common.o
unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
C compiler or Python headers are not installed on this system. Try to run:
sudo apt-get install gcc python3-dev
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/tony/venv/bin/python3 -u -c 'import sys, setupt
ools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nhmrc04p/psutil/setup.py'"'"'; file='"'"'/tm
p/pip-install-nhmrc04p/psutil/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code
=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"
'))' install --record /tmp/pip-record-sadb45gi/install-record.txt --single-version-externally-manage
d --compile --install-headers /home/tony/venv/include/site/python3.6/psutil Check the logs for full
command output.
What can be alternative to
$ sudo su
\# echo 'net.ipv4.ip_unprivileged_port_start=0' > /etc/sysctl.d/50-unprivileged-ports.conf
\# sysctl --system
when it's not possible to go with it?
Thanks and have a nice day!
is it intended?
I guess it is set to refresh/re download assets automatically when it is updated. However it is always set to 0.
for example <link rel="stylesheet" href="/_/static/runtime/css/bootstrap-theme.min.css?buildTime=0" crossorigin/>
So, whenever I upgrade anvil-app-server using pip, client have to use force refresh option on web browser.
Do I have to change source code and build it myself?
In case of run the app on the anvil cloud, it is served with
<link rel="stylesheet" href="https://anvil.works/runtime-new/runtime/css/bootstrap-theme.min.css?sha=34b102cb7689409fd1c3c180aeb1fd3f0b8bf0b47ab25c74c42eaff574e661a9" crossorigin/>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.