Commit Graph

140 Commits

Author SHA1 Message Date
Miguel de la Cruz
2259b7f2a8 [MM-19948] Set version on module file and internal paths (#13186)
* [MM-19948] Set version on module file and internal paths

* Fixes after merge

* Fix i18n checker error
2019-11-28 14:39:38 +01:00
Christopher Speller
8429add371 Cleanup related to context refactor (#9988) 2018-12-17 08:51:46 -08:00
Jesse Hallam
0ba0af889e MM-6839: searching for paths relative to executable (#8915)
* MM-6839: search relative to executable (#8853)

* MM-6839: searching for paths relative to executable

In addition to searching relative to the current working directory, also
search relative to the location of the binary. This helps locate config
and i18n files when invoking an absolute path to the mattermost binary.

* MM-6839: find mattermost/ binary using utils.FindFile

* add unit tests for utils.FindFile to exclude directories

* fix filtering out directories in FindFile

* fix platform invoking ./bin/mattermost
2018-06-06 07:18:24 -07:00
Christopher Speller
2f6039f23f Revert "MM-6839: search relative to executable (#8853)" (#8876)
This reverts commit d3cf110620.
2018-05-29 13:21:42 -07:00
Jesse Hallam
d3cf110620 MM-6839: search relative to executable (#8853)
* MM-6839: searching for paths relative to executable

In addition to searching relative to the current working directory, also
search relative to the location of the binary. This helps locate config
and i18n files when invoking an absolute path to the mattermost binary.

* MM-6839: find mattermost/ binary using utils.FindFile
2018-05-29 10:55:49 -04:00
Christopher Speller
11cbb59747 Renaming platform binary to mattermost. (#8801) 2018-05-17 12:40:40 -07:00
Jesús Espino
b2dd00dd5b Adding enterprise commands support (#8327) 2018-03-07 20:04:18 +00:00
Chris
e8943936c5 general cleanup (#8387) 2018-03-07 12:36:40 -06:00
Jesús Espino
342d05bcfc Adding saml migration command (#8263)
* Adding saml migration command

* Texts fixed
2018-02-21 14:34:03 +01:00
Christopher Speller
6d8f122a51 Upgrading server dependancies (#8308) 2018-02-16 09:47:51 -05:00
Pierre de La Morinerie
b112747de7 Send systemd READY notification (#8296)
Currently, when starting Mattermost programmatically, it's hard to tell
when the server is actually ready to receive network connections.

This isn't convenient for monitoring (the systemd service status is
"running" although the server is still booting), nor for programatic use
(where a script would need to know when the server is ready to perform
further actions).

To improve this, systemd allow processes to tell when they started
successfully. The launcher waits for this notification before
reporting the service as successfully launched.

The way processes notify systemd is by sending a `READY=1` string over
a standard unix socket, whose path is provided in an environment var.

The systemd service is then told to expect this notification:

```diff
 [Service]
-Type=simple
+Type=notify
 ExecStart=/home/vagrant/go/bin/platform
```

Now, when starting the server, systemd will actually wait for the server to
be ready before returning the control to the shell.

Additionally, during this time, querying the server status with
`service mattermost status` will report the service as "activating" – before
transitioning to "running" when the server is ready.
2018-02-15 16:47:03 -08:00
Pierre de La Morinerie
44a27125de Wait for goroutines to finish before shuting down server (#8259)
When running server tests, the server will exit while some jobs spawned
through a goroutine are still running. This may crash the test harness,
as the jobs try to access a shut down app instance.

Fortunately the fix is easy: we just have to use the same App
goroutine-counting facility than the rest of the method's goroutines.
2018-02-14 12:18:06 -06:00
Pierre de La Morinerie
07fd7aeeb8 Add tests for the platform server command (#8231)
* Cleanup app state on initialization error

When returning an initialization error, the app state was not cleaned
up. This is especially visible during tests, as `appCount` is not
decremented, and makes the new app initialization fail.

* Test the `platform server` command

As the `platform server` command only exits when interrupted by
a signal, it is not possible to test it as the other cobra
commands. Instead we directly test the actual command function.

The internal command handler is slighly refactored to take
a channel in argument, and registers it as the signal handler.
Nothing very different—except than controlling this channel
from the outside allows the test to send the system signal
itself, thus preventing the server to run forever.
2018-02-12 08:46:32 -08:00
Chris
a6309aaf48 Remove license globals entirely (#8229)
* remove license globals entirely

* fix infinite recursion

* test fix
2018-02-09 10:04:48 -06:00
Vordimous
7bd298ceaa PLT-7537: Move channel CLI command posts system message to channel. (#8161)
* [PTL-7537] implement feature and test

* [PTL-7537] Update feature to post the the room requiring a username flag to be used

* [PTL-7537] update tests with username

* update test to remove changes to the test helper struct

* use the basic team and user
2018-02-07 14:17:18 +00:00
Pierre de La Morinerie
809a16458f Abort on critical error during server startup (#8204)
Only a handful of critical errors are present in the codebase.
They all occur during server startup (in `app.StartServer()`).

Currently, when one of these critical error occurs, it is simpled
mentionned in the logs – then the error is discarded, and the app
attempts to continue the execution (and probably fails pretty quickly in
a weird way).

Rather than continuing operations in an unknow state, these errors should
trigger a clean exit.

This commit rewrites critical startup errors to be correctly
propagated, logged, and then terminate the command execution.
Additionnaly, it makes the server return a proper error code to the
shell.
2018-02-07 02:11:15 -06:00
Chris
1ec295f88c add App.License, remove utils.IsLicensed / utils.License calls (#8203) 2018-02-06 17:25:49 -06:00
Pierre de La Morinerie
07902b4c91 report server launch errors (#8189)
When starting the server using `platform server`, errors occuring during
startup are not reported in the console. The command exit with a 0 exit
code (i.e. "success"), although the server failed to launch.

With this change, when an error occurs while initializing the app (like
a missing or invalid configuration file):

- the error is printed to the console;
- the command exit with a "-1" exit code.

This allow shell scripts to properly detect the startup failure, and to
react to it.

Example of error displayed:

```
$ platform server
Error: LoadConfig: Error decoding config file=config.json, err=While parsing config: invalid character ':' after top-level value,
``
2018-02-02 11:54:14 -06:00
Jesús Espino
f988e5bc30 Use default configurations for user-0 in sampledata (#8174) 2018-01-31 16:31:49 -08:00
Christopher Speller
961c04cae9 Upgrading server dependancies (#8154) 2018-01-29 14:17:40 -08:00
Evgeniy
9d6a9ff4be Post a system message to the affected channel by CLI command (#7877) (#7968) 2018-01-18 16:05:00 -05:00
Chris
4e6cc846a6 Finally remove utils.Cfg (#8113)
* finally remove utils.Cfg

* fix compile error

* another test compilation fix
2018-01-17 13:38:37 -05:00
Joram Wilander
dce0616305 ABC-73 Move session clean-up to daily task (#8095)
* Move session clean-up to daily task

* Split delete query into batches
2018-01-17 08:50:49 -05:00
Chris
7e5ce97668 Remove global cfg vars (#8099)
* remove global cfg vars

* enterprise update
2018-01-12 09:02:11 -05:00
Chris
1d9efd0e39 Remove global config watcher (#8080)
* remove global config watcher

* keep config watcher disabled for tests

* compile fix

* fix resource leak
2018-01-11 13:23:41 -08:00
Jesús Espino
6990d052d5 [XYZ-6] Add sampledata platform command (#8027)
* Add fake dependency

* [XYZ-6] Add sampledata platform command

* Creating EMOJI_NAME_MAX_LENGTH as a constant and using it where needed
2018-01-11 10:57:47 -05:00
Jesús Espino
dd9ad10d70 [PLT-6936] Translate AppError.Message automatically by default (#8063) 2018-01-08 13:13:24 -05:00
Chris
591ef9f352 Remove utils.ClientCfg and utils.ClientCfgHash (#8041)
* remove utils.ClientCfg and utils.ClientCfgHash

* remove unused import
2018-01-05 16:17:57 -06:00
Chris
66bdf830b5 disable config watching during cli tests (#8040) 2018-01-05 13:33:07 -06:00
Chris
4c17bdff1b Add plugin slash command support (#7941)
* add plugin slash command support

* remove unused string

* rebase
2017-12-08 13:55:41 -06:00
Joram Wilander
617a98d6d8 Allow deactivation of SSO users (#7952) 2017-12-08 11:14:55 -08:00
Harrison Healey
36777057f2 PLT-8289 Added ability to change location of client plugins (#7942) 2017-12-05 12:25:49 -06:00
Jonathan
375c0632fa PLT-7503: Create Message Export Scheduled Task and CLI Command (#7612)
* Created message export scheduled task

* Added CLI command to immediately kick off an export job

* Added email addresses for users joining and leaving the channel to the export

* Added support for both MySQL and PostgreSQL

* Fixing gofmt error

* Added a new ChannelMemberHistory store and associated tests

* Updating the ChannelMemberHistory channel as users create/join/leave channels

* Added user email to the message export object so it can be included in the actiance export xml

* Don't fail to log a leave event if a corresponding join event wasn't logged

* Adding copyright notices

* Adding message export settings to daily diagnostics report

* Added System Console integration for message export

* Cleaned up TODOs

* Made batch size configurable

* Added export from timestamp to CLI command

* Made ChannelMemberHistory table updates best effort

* Added a context-based timeout option to the message export CLI

* Minor PR updates/improvements

* Removed unnecessary fields from MessageExport object to reduce query overhead

* Removed JSON functions from the message export query in an effort to optimize performance

* Changed the way that channel member history queries and purges work to better account for edge cases

* Fixing a test I missed with the last refactor

* Added file copy functionality to file backend, improved config validation, added default config values

* Fixed file copy tests

* More concise use of the testing libraries

* Fixed context leak error

* Changed default export path to correctly place an 'export' directory under the 'data' directory

* Can't delete records from a read replica

* Fixed copy file tests

* Start job workers when license is applied, if configured to do so

* Suggestions from the PR

* Moar unit tests

* Fixed test imports
2017-11-30 09:07:04 -05:00
Chris
816a30397d Role refactor (#7867)
* role refactor

* add missing file

* fix web test
2017-11-21 11:08:32 -08:00
Jesús Espino
e2b165cf3e Small fix to run webapp tests (#7777) 2017-11-20 15:53:46 -08:00
Chris
5cf45d2155 refactor template code (#7860) 2017-11-20 12:57:45 -05:00
Tsilavina Razafinirina
ab6ef954b4 PLT-6217 Fixes system message posted to Town Square when a member leaves a team (#7752)
* Fixes system message posted to Town Square when adding/removing team member (#6483)

Fixes unit test method call to match RemoveUserFromTeam modification (#6483)

Fixes system message posted to Town Square when adding/removing team member (#6483)

Removes unnessary error message

* Updates system message when a user leaves a team (#6483)

* Changes system message when a user is removed from team (#6483)

* Adds a new string to be post to town-square when a member is added to a team (#6483)
2017-11-20 10:15:33 -05:00
Chris
065d8e9731 make config validate exit with non-zero code on failure (#7855) 2017-11-17 11:27:26 -03:00
Chris
eb1a00ef5f Reorganize file util functionality (#7848)
* reorganize file util functionality

* fix api test compilation

* fix rebase issue
2017-11-16 16:04:27 -05:00
Chris
ef69d93abf add one more config test (#7853) 2017-11-16 12:08:07 -05:00
Chris
bf6bb9bce9 fix config cli option (#7850) 2017-11-16 08:40:26 -06:00
Chris
865f9f83a7 Improve test coverage reporting / accuracy (#7819)
* improve test coverage reporting / accuracy

* handle absolute coverpaths

* move tests into multiple files

* rename codecov.yml (https://github.com/codecov/support/issues/426)
2017-11-13 11:59:51 -08:00
Christopher Speller
1329aa51b6 Updating server dependancies. (#7816) 2017-11-13 09:09:58 -08:00
Chris
10c5a927cb more global config ref cleanup (#7802) 2017-11-09 14:46:20 -06:00
Chris
61db2ff59b fix builtin plugin http router (#7797) 2017-11-06 19:53:40 -08:00
George Goldberg
72ae0ab9bb PLT-8011: Make Elasticsearch startup fully async. (#7761)
* PLT-8011: Make Elasticsearch startup fully async.

* Use a.Go
2017-11-06 10:05:28 -08:00
Joram Wilander
2acb548615 PLT-8086 Fix plugin config watcher for enabling and disabling (#7770)
* Fix plugin config watcher for enabling and disabling

* Make sure HTTP routes are served

* Set content-type explicitly
2017-11-03 17:47:52 -04:00
Chris
d5dbdb2737 several one-line panic, race, and logic fixes (#7766) 2017-11-03 08:25:38 -07:00
Joram Wilander
06ec648cf3 PLT-7978 Add websocket event for user role update (#7745)
* Add websocket event for user role update

* Fix tests

* More test fixes
2017-10-31 16:00:21 +00:00
Chris
ce2b2be5de Refactoring cfg refs and load / save functions (#7749)
* refactoring cfg refs and load / save functions

* improve error output
2017-10-31 10:39:31 -04:00