- Move all repo's from master to main default branch.
Prequisites:
- Set up Postgres 13
- Recommended: Install pgadmin4
Installing and executing:
- In the README it is unclear how to set up https for localhost (where to place generated keys).
- Had to copy 'example' from
bin
to theapcore/example
folder. - Created the self-signed certificate in this dir.
- Can use a config file here, to avoid all the cmd-line questions
Various remarks:
- Backspace in terminal during config gives annoying 'bump' sound. Same with arrow movement.
- On command-line option selection, only the result not the question is displayed, after a choice was made.
- The cursor character █ covers the first char of default values in
configure
, making them unreadable. - When text doesn't fit terminal line, and you keep typing, then on each character entered the entire line is repeated twice:
✔ Please enter an account contact information (username, webfinger address, email address, etc) for the organization's contact for this server. This may be made avialable to the public:example_account_cont
✔ Please enter an account contact information (username, webfinger address, email address, etc) for the organization's contact for this server. This may be made avialable to the public:example_account_cont
✔ Please enter an account contact information (username, webfinger address, email address, etc) for the organization's contact for this server. This may be made avialable to the public:example_account_cont
✔ Please enter an account contact information (username, webfinger address, email address, etc) for the organization's contact for this server. This may be made avialable to the public:example_account_cont
✔ Please enter an account contact information (username, webfinger address, email address, etc) for the organization's contact for this server. This may be made avialable to the public:example_account_cont
✔ Please enter an account contact information (username, webfinger address, email address, etc) for the organization's contact for this server. This may be made avialable to the public:example_account_contact
- The
/templates
subdir needs to be available in the folder where theexample
executable resides.- Otherwise (contains backticks):
panic: html/template: pattern matches no files: ``templates/*.tmpl``
- Otherwise (contains backticks):
Example configure command-line output:
22:07 $ ./example configure
INFO : 2021/01/08 22:07:35.717756 app.go:88: Templates found:
INFO : 2021/01/08 22:07:35.717824 app.go:90: header.tmpl
INFO : 2021/01/08 22:07:35.717836 app.go:90: inline_css.tmpl
INFO : 2021/01/08 22:07:35.717843 app.go:90: list_users.tmpl
INFO : 2021/01/08 22:07:35.717850 app.go:90:
INFO : 2021/01/08 22:07:35.717857 app.go:90: auth.tmpl
INFO : 2021/01/08 22:07:35.717865 app.go:90: not_found.tmpl
INFO : 2021/01/08 22:07:35.717872 app.go:90: note.tmpl
INFO : 2021/01/08 22:07:35.717880 app.go:90: list_notes.tmpl
INFO : 2021/01/08 22:07:35.717889 app.go:90: nav.tmpl
INFO : 2021/01/08 22:07:35.717900 app.go:90: create_note.tmpl
INFO : 2021/01/08 22:07:35.717917 app.go:90: home.tmpl
INFO : 2021/01/08 22:07:35.717925 app.go:90: inbox.tmpl
INFO : 2021/01/08 22:07:35.717932 app.go:90: internal_error.tmpl
INFO : 2021/01/08 22:07:35.717939 app.go:90: login.tmpl
INFO : 2021/01/08 22:07:35.717945 app.go:90: not_allowed.tmpl
INFO : 2021/01/08 22:07:35.717951 app.go:90: outbox.tmpl
INFO : 2021/01/08 22:07:35.717959 app.go:90: user.tmpl
INFO : 2021/01/08 22:07:35.717965 app.go:90: bad_request.tmpl
INFO : 2021/01/08 22:07:35.717971 app.go:90: followers.tmpl
INFO : 2021/01/08 22:07:35.717977 app.go:90: following.tmpl
INFO : 2021/01/08 22:07:35.717982 app.go:90: footer.tmpl
______________________________________________________
\__/ / Welcome to the configuration guided flow! Here we \
\------(oo) / will visit common configuration choices. While not |
|| (__) < every option is asked in the guided flow, you can |
||w--|| | always open the resulting configuration file to |
| change options. You can also change your answers to |
| this flow. Note that in order to take advantage of |
| changed configuration values, the application will |
| need to be restarted. Let's go! |
\-------------------------------------------------------/
✔ postgres
✔ Enter the host for this server (ignored in debug mode):example.com
✔ Enter the path to the file containing the certificate used in HTTPS connections:./cert.pem
✔ Enter the path to the file containing the private key for the certificate used in HTTPS connections:./key.pem
✔ Enter the directory for serving static content (WARNING: Everything in it will be served)?:static
✔ Do you already have a file containing a cookie authentication private key? [y/N]N█
✔ Enter the new file name for the cookie authentication private key:█ookie_authn.key
✔ Do you already have a file containing a cookie encryption private key? [y/N]N
✔ Do you want to use a cookie encryption private key? [y/N]y
✔ Enter the new file name for the cookie encryption private key:cookie_enc.key
✔ Session name used to find cookies:█y_apcore_session_name
✔ Enter the deadline (in seconds) for reading & writing HTTP & HTTPS requests. A value of zero means connections do not timeout:60
✔ Please enter an IANA Time Zone for the server, "UTC", or "Local":Local
✔ Please enter the steady-state rate limit for outbound ActivityPub QPS:2
✔ Please enter the burst limit for outbound ActivityPub QPS:5
✔ Enter the maximum lifetime (in seconds) for database connections. A value of zero means connections do not timeout:60
✔ Enter the maximum number of database connections allowed. A value of zero means infinite are permitted.:0
Prompting for Postgres database configuration options...
✔ Enter the postgres user name:gofeduser
✔ Enter the postgres database port:5432█
Enter the postgres database password: *********
✔ disable
✔ Enter the postgres database name:gofed
✔ Enter the postgres schema name:public
INFO : 2021/01/08 22:10:52.462357 cmdline.go:285: Calling application to get default config options
INFO : 2021/01/08 22:10:52.462396 config.go:156: Saving config file: config.ini
INFO : 2021/01/08 22:10:52.463390 cmdline.go:301: Successfully wrote configuration file to config.ini
- Needed to create 'gofeduser', and had to give login privilege
- Created 'gofed' db with gofeduser as owner with 'Log in' privlege and having at least 'Create' privilege on the db (I then granted full privilege for gofeduser, so don't know exactly what else may be required).
- Otherwise (error shown twice, uses backticks):
run.go:93: error running init-db: failed to connect to ``host=localhost user=gofeduser database=gofed``: server error (FATAL: role "gofeduser" is not permitted to log in (SQLSTATE 28000))
- Otherwise (error shown twice, uses backticks):
- Had to manually execute on
gofed
db:CREATE EXTENSION IF NOT EXISTS "pgcrypto";
- Otherwise (error shown twice):
run.go:93: error running init-db: ERROR: function gen_random_uuid() does not exist (SQLSTATE 42883)
- Otherwise (error shown twice):
Example init-db command-line output:
23:06 $ ./example init-db
INFO : 2021/01/08 23:16:31.179154 app.go:88: Templates found:
INFO : 2021/01/08 23:16:31.180465 app.go:90: note.tmpl
INFO : 2021/01/08 23:16:31.180474 app.go:90: following.tmpl
INFO : 2021/01/08 23:16:31.180482 app.go:90: inline_css.tmpl
INFO : 2021/01/08 23:16:31.180489 app.go:90: internal_error.tmpl
INFO : 2021/01/08 23:16:31.180498 app.go:90: list_notes.tmpl
INFO : 2021/01/08 23:16:31.180505 app.go:90: nav.tmpl
INFO : 2021/01/08 23:16:31.180512 app.go:90: not_allowed.tmpl
INFO : 2021/01/08 23:16:31.180519 app.go:90:
INFO : 2021/01/08 23:16:31.180525 app.go:90: header.tmpl
INFO : 2021/01/08 23:16:31.180532 app.go:90: inbox.tmpl
INFO : 2021/01/08 23:16:31.180542 app.go:90: login.tmpl
INFO : 2021/01/08 23:16:31.180552 app.go:90: outbox.tmpl
INFO : 2021/01/08 23:16:31.180562 app.go:90: user.tmpl
INFO : 2021/01/08 23:16:31.180587 app.go:90: bad_request.tmpl
INFO : 2021/01/08 23:16:31.180597 app.go:90: followers.tmpl
INFO : 2021/01/08 23:16:31.180608 app.go:90: home.tmpl
INFO : 2021/01/08 23:16:31.180621 app.go:90: list_users.tmpl
INFO : 2021/01/08 23:16:31.180630 app.go:90: auth.tmpl
INFO : 2021/01/08 23:16:31.180640 app.go:90: create_note.tmpl
INFO : 2021/01/08 23:16:31.180649 app.go:90: footer.tmpl
INFO : 2021/01/08 23:16:31.180658 app.go:90: not_found.tmpl
______________________________________________________
\__/ / We're connecting to the database using the specs in \
\------(oo) / the config file, creating tables, seeding initial |
|| (__) < data, and then closing all connections. |
||w--|| \-------------------------------------------------------/
INFO : 2021/01/08 23:16:31.181139 config.go:123: Loading config file: config.ini
INFO : 2021/01/08 23:16:31.181839 db.go:84: Postgres database configuration
INFO : 2021/01/08 23:16:31.181868 db.go:46: Calling sql.Open...
INFO : 2021/01/08 23:16:31.182496 db.go:51: Calling sql.Open complete
INFO : 2021/01/08 23:16:31.182511 db.go:65: Database connections configured successfully
INFO : 2021/01/08 23:16:31.182522 db.go:66: NOTE: No underlying database connections may have happened yet!
______________________________________________________
\__/ / \
\------(oo) / Next up is seeeeding the database with basic |
|| (__) < information to get your server Moooooving~. |
||w--|| \-------------------------------------------------------/
INFO : 2021/01/08 23:16:31.484494 config.go:123: Loading config file: config.ini
INFO : 2021/01/08 23:16:31.484893 db.go:84: Postgres database configuration
INFO : 2021/01/08 23:16:31.484914 db.go:46: Calling sql.Open...
INFO : 2021/01/08 23:16:31.484939 db.go:51: Calling sql.Open complete
INFO : 2021/01/08 23:16:31.484947 db.go:65: Database connections configured successfully
INFO : 2021/01/08 23:16:31.484957 db.go:66: NOTE: No underlying database connections may have happened yet!
______________________________________________________
\__/ / We're now going to prompt for optional information \
\------(oo) / about your server and the organization running it, in |
|| (__) < order to complete the server profile. |
||w--|| \-------------------------------------------------------/
INFO : 2021/01/08 23:16:31.574260 config.go:123: Loading config file: config.ini
INFO : 2021/01/08 23:16:31.574550 db.go:84: Postgres database configuration
INFO : 2021/01/08 23:16:31.574567 db.go:46: Calling sql.Open...
INFO : 2021/01/08 23:16:31.574581 db.go:51: Calling sql.Open complete
INFO : 2021/01/08 23:16:31.574595 db.go:65: Database connections configured successfully
INFO : 2021/01/08 23:16:31.574608 db.go:66: NOTE: No underlying database connections may have happened yet!
✔ Please enter the name of the organization this server belongs to. This may be made available to the public:example_org
✔ Please enter the name of the organization's contact for this server. This may be made avialable to the public:example_contact
✔ Please enter an account contact information (username, webfinger address, email address, etc) for the organization's contact for this server. This may be made avialable to the public:example_account_contact
✔ Please enter this server's name, which may be publicly shared:example_org_server
✔ Are registrations on this server open to the general public? [y/N]N█
- Loading templates appears to occur in random order (bit confusing)
Example init-admin command-line output:
$ ./example init-admin
INFO : 2021/01/09 08:24:05.429410 app.go:88: Templates found:
INFO : 2021/01/09 08:24:05.430731 app.go:90: header.tmpl
INFO : 2021/01/09 08:24:05.430743 app.go:90: login.tmpl
INFO : 2021/01/09 08:24:05.430753 app.go:90: not_found.tmpl
INFO : 2021/01/09 08:24:05.430762 app.go:90:
INFO : 2021/01/09 08:24:05.430772 app.go:90: create_note.tmpl
INFO : 2021/01/09 08:24:05.430783 app.go:90: footer.tmpl
INFO : 2021/01/09 08:24:05.430795 app.go:90: nav.tmpl
INFO : 2021/01/09 08:24:05.430807 app.go:90: outbox.tmpl
INFO : 2021/01/09 08:24:05.430819 app.go:90: followers.tmpl
INFO : 2021/01/09 08:24:05.430829 app.go:90: inline_css.tmpl
INFO : 2021/01/09 08:24:05.430838 app.go:90: list_notes.tmpl
INFO : 2021/01/09 08:24:05.430848 app.go:90: bad_request.tmpl
INFO : 2021/01/09 08:24:05.430859 app.go:90: home.tmpl
INFO : 2021/01/09 08:24:05.430868 app.go:90: note.tmpl
INFO : 2021/01/09 08:24:05.430877 app.go:90: internal_error.tmpl
INFO : 2021/01/09 08:24:05.430898 app.go:90: list_users.tmpl
INFO : 2021/01/09 08:24:05.430907 app.go:90: not_allowed.tmpl
INFO : 2021/01/09 08:24:05.430916 app.go:90: user.tmpl
INFO : 2021/01/09 08:24:05.430925 app.go:90: auth.tmpl
INFO : 2021/01/09 08:24:05.430934 app.go:90: following.tmpl
INFO : 2021/01/09 08:24:05.430942 app.go:90: inbox.tmpl
______________________________________________________
\__/ / \
\------(oo) / Moo~, let's create an administrative account! |
|| (__) < |
||w--|| \-------------------------------------------------------/
INFO : 2021/01/09 08:24:05.431404 config.go:123: Loading config file: config.ini
INFO : 2021/01/09 08:24:05.431950 db.go:84: Postgres database configuration
INFO : 2021/01/09 08:24:05.431975 db.go:46: Calling sql.Open...
INFO : 2021/01/09 08:24:05.432564 db.go:51: Calling sql.Open complete
INFO : 2021/01/09 08:24:05.432578 db.go:65: Database connections configured successfully
INFO : 2021/01/09 08:24:05.432588 db.go:66: NOTE: No underlying database connections may have happened yet!
✔ Enter the new admin account's username:gofedadmin█
✔ Enter the new admin account's email address (will NOT be verified):gofedadmin@example.com█
Enter the new admin account's password: *********
______________________________________________________
\__/ / \
\------(oo) / New admin account successfully created! Moo~ |
|| (__) < |
||w--|| \-------------------------------------------------------/
Example serve command-line output:
$ ./example serve
INFO : 2021/01/09 08:30:37.691362 app.go:88: Templates found:
INFO : 2021/01/09 08:30:37.691459 app.go:90: inbox.tmpl
INFO : 2021/01/09 08:30:37.691472 app.go:90: user.tmpl
INFO : 2021/01/09 08:30:37.691483 app.go:90: footer.tmpl
INFO : 2021/01/09 08:30:37.691493 app.go:90: home.tmpl
INFO : 2021/01/09 08:30:37.691505 app.go:90: list_notes.tmpl
INFO : 2021/01/09 08:30:37.691516 app.go:90: login.tmpl
INFO : 2021/01/09 08:30:37.691527 app.go:90: nav.tmpl
INFO : 2021/01/09 08:30:37.691539 app.go:90:
INFO : 2021/01/09 08:30:37.691550 app.go:90: bad_request.tmpl
INFO : 2021/01/09 08:30:37.691557 app.go:90: followers.tmpl
INFO : 2021/01/09 08:30:37.691564 app.go:90: inline_css.tmpl
INFO : 2021/01/09 08:30:37.691571 app.go:90: not_allowed.tmpl
INFO : 2021/01/09 08:30:37.691581 app.go:90: outbox.tmpl
INFO : 2021/01/09 08:30:37.691591 app.go:90: auth.tmpl
INFO : 2021/01/09 08:30:37.691598 app.go:90: create_note.tmpl
INFO : 2021/01/09 08:30:37.691618 app.go:90: following.tmpl
INFO : 2021/01/09 08:30:37.691625 app.go:90: not_found.tmpl
INFO : 2021/01/09 08:30:37.691632 app.go:90: note.tmpl
INFO : 2021/01/09 08:30:37.691639 app.go:90: header.tmpl
INFO : 2021/01/09 08:30:37.691650 app.go:90: internal_error.tmpl
INFO : 2021/01/09 08:30:37.691657 app.go:90: list_users.tmpl
INFO : 2021/01/09 08:30:37.691679 config.go:123: Loading config file: config.ini
INFO : 2021/01/09 08:30:37.692001 db.go:84: Postgres database configuration
INFO : 2021/01/09 08:30:37.692019 db.go:46: Calling sql.Open...
INFO : 2021/01/09 08:30:37.692066 db.go:51: Calling sql.Open complete
INFO : 2021/01/09 08:30:37.692077 db.go:65: Database connections configured successfully
INFO : 2021/01/09 08:30:37.692100 db.go:66: NOTE: No underlying database connections may have happened yet!
INFO : 2021/01/09 08:30:37.736351 sessions.go:42: Cookie encryption key file detected
INFO : 2021/01/09 08:30:37.736673 handler.go:77: Serving static directory: static
INFO : 2021/01/09 08:30:37.738980 db.go:71: Opening connection to database by pinging, which will create a connection...
INFO : 2021/01/09 08:30:37.739208 db.go:79: Successfully pinged database with latency: 174.606µs
INFO : 2021/01/09 08:30:37.739234 server.go:139: Preparing models
INFO : 2021/01/09 08:30:37.739252 server.go:145: Starting internal systems
INFO : 2021/01/09 08:30:37.739329 server.go:149: Starting application
INFO : 2021/01/09 08:30:37.739364 server.go:171: Launching https server
INFO : 2021/01/09 08:30:37.739428 server.go:163: Starting http redirection server
ERROR: 2021/01/09 08:30:37.741953 server.go:176: Error shutting down https server: listen tcp :443: bind: permission denied
ERROR: 2021/01/09 08:30:37.741953 server.go:176: Error shutting down https server: listen tcp :443: bind: permission denied
Trying to fix: I did a go clean
, new folder, running configure + init-db a second time:
- Since I got an error in
example serve
dealing with SSL (see below), this time I specified full path for key + certificate. - I did not clean, or delete/recreate database.
- Error in init-db (shown twice):
run.go:93: error running init-db: user does not have a unique preferredUsername
- Entirely dropping the db and recreating it fixed this problem.
- End result. Same error on
serve
:server.go:176: Error shutting down https server: listen tcp :443: bind: permission denied
As discussed with @cjslep on Matrix: